I'm searching a way to instatiate a new ember object with the classname as a string:
App.MyObject = Ember.Object.extend({hello:'hello'});
//Try to do something like this.
App.myObject = Ember.create("App.MyObject", {hello:'Hello World!'});
console.log(App.myObject.hello); //productes 'Hello World!'
Is there a possibility to do something like this?
I think you dont need to use getters and setters in your special case.
Your solution was
Ember.get(window, "App.MyObject").create({hello:'Hello World!'});
But I think a simple one like:
var className = "MyObject";
App[className].create({hello:'Hello World!'});
will work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.