将参数传递给ember.js中的init [英] Passing arguments to init in ember.js

查看:77
本文介绍了将参数传递给ember.js中的init的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何传递参数到 init()或访问传递给的参数create()里面 init()在ember.js

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

推荐答案

只需使用 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);

这篇关于将参数传递给ember.js中的init的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆