我需要在创建特定对象时运行一个函数来验证环境设置是否正确。
这适用于Ember.Controller,但不适用于Ember.Object。
checkEnvironment : function() {
...
}.on('init'),
有没有办法以某种方式挂钩到构造函数?
答案 0 :(得分:1)
函数实际上没有on
方法,也许您会将它们与observers混淆?
fullNameChanged: function() {
// deal with the change
}.observes('fullName').on('init')
您可以做的是覆盖init
methid,并致电this._super()
init: function() {
this._super();
this.checkEnvironment();
},