Reputation: 50750
import Ember from 'ember';
import myConst from '../utils/constants';
export default Ember.Mixin.create(myConst, {
getFieldId: function(productCode) {
console.log(myConst.MY_METHODS.FIELD_ID); //Not able to access this
}
});
My constants.js looks like
var myConst = {};
myConst.MY_METHODS = {
FIELD_ID: "fieldId"
};
export default myConst;
I am unable to access myConst inside the mixin. What am I doing wrong ?
Upvotes: 1
Views: 466
Reputation: 1435
I think you're confusing a couple of concepts here. In your example, myConst
is a utility module that contains some default values, right? In that case, you don't want to mix it in to your mixin (which is what you're doing with Ember.Mixin.create(myConst, {...})
. You should be doing something like this:
import Ember from 'ember';
import myConst from '<app-name>/utils/constants';
export default Ember.Mixin.create({
getFieldId: function(productCode) {
console.log(myConst.MY_METHODS.FIELD_ID);
}
});
If that doesn't work, it's likely something to do with your import
path. I would start debugging by just console.log
ing myConst
to make sure you have the intended object from your module.
Upvotes: 2