Passing arguments to init in ember.js

前端 未结 2 1026
陌清茗
陌清茗 2021-02-18 16:18

How can I pass arguments to init() or access the arguments passed to create() inside init() in ember.js

2条回答
  •  悲哀的现实
    2021-02-18 16:43

    Just use this.get('theProperty')

    Example:

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

提交回复
热议问题