how would one create a constants class or helper in Ember?
something like create a constants.js and add
export const testme = 3;
export const testtoo = 4;
then in a controller I'd
import constants from 'constants';
you are exporting correctly but importing incorrectly your import should look like this
import { testme, testtoo } from './constants';
but I would take different approach and create hash constant instead (in constants.js file)
export default { TEST1: '1', TEST2: '2' };
then import like
import CONSTANTS from 'constants'
CONSTANTS.TEST1 === '1'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With