dimanche 4 décembre 2016

Class and scope in ember js?

Im building an ember application consuming a couple of web services. And I'm trying to pass a class object throw the config/environment file doing this:

var myclass = require('myclass-package');

var ENV = {
    APP: {
       MY_OBJ_CLASS: new myclass({
                        //CONSTRUCTOR PARAMS...
                        PROP1: "HELLO"
                     }) 
    }
}

In my ember app/controllers I'm doing this:

import ENV from '../config/environment';
var obj1 = ENV.APP.MY_OBJ_CLASS;

I can see that the object is instantiated if I console.log the class object but when I try to access to the properties and functions, I can't and I get back this error:

var data = obj1.my_function_class({param1:1});
console.log(data)
TypeError: obj1.my_function_class is not a function

But the function exist... What is the way to access to my class properties and functions?




Aucun commentaire:

Enregistrer un commentaire