Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How declare a constants file with Ember.js

Tags:

ember.js

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';
like image 929
hal9000 Avatar asked Mar 13 '23 18:03

hal9000


1 Answers

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'
like image 152
Bek Avatar answered Mar 28 '23 23:03

Bek