0

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?

devrys
  • 1,571
  • 3
  • 27
  • 43
claudiocro
  • 83
  • 1
  • 5

1 Answers1

0

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.

sabithpocker
  • 15,274
  • 1
  • 42
  • 75