我正在尝试使用 Ember 从我的视图中调用我的控制器的操作,但它说:
Uncaught TypeError: Cannot call method 'send' of null
我只是找不到在 ember 中处理视图的正确方法。
我的视图布局有这样的调用:
<button type="button" {{action modalConfirmation target="view"}} class="btn btn-primary">Save changes</button>
我的 View 类尝试以这种方式调用控制器:
this.get('controller').modalConfirmation();
我的控制器有这样的东西:
ProjEmber.BananasIndexController = Ember.ArrayController.extend({
actions: {
showModal: function() {
modalinaView.title = "My Title";
modalinaView.templateName = "any_template_you_wish";
modalinaView.append();
},
modalConfirmation: function() {
console.debug('Action modalConfirmation');
}
}
});
OBS:如果我使用这样的助手附加我的视图,它会起作用:
{{#view ProjEmber.ModalinaView title='A title'}}
A not so good application of a modal view. Just for the sake of illustration.
{{/view}}
您可以在 Github 上查看完整源代码,特别是提交的这一部分: https ://github.com/lucaspottersky/ember-lab/commit/4862426b39adc0bbcce0b4cc3fd0099439f8dd55#commitcomment-4421854