在ember.js中将参数传递给init

Sel*_*M A 21 javascript ember.js

如何在ember.js中传递参数init()或访问传递给create()内部的参数init()

Ili*_*oly 22

只是用 this.get('theProperty')

例:

var data = {
    foo: "hello",
};

var MyModel = Em.Object.extend({
    init: function() {
        this._super();
        var foo = this.get('foo');
        alert(foo);
    }
});

MyModel.create(data);
Run Code Online (Sandbox Code Playgroud)