2016-04-23 56 views
4

为什么不点击下面模板中描述的按钮按预期工作? This blog post does the exact same thingngClick事件在Angular 1.5.5组件中未触发

'use strict'; 

angular.module('core').component('foo', { 
    bindings: { 
     items: '<', 
    }, 
    controller: function() { 
     function fire() { 
      console.log('hello'); 
     } 
    }, 
    template: "<button type='button' ng-click='$ctrl.fire();'>Test</button>" 
}); 

编辑:增加了更加清晰的问题

+0

*“为什么不按预期工作?”*。没有人知道你期望什么,你会得到什么。 – dfsq

+0

代码的标题和上下文是否不足以推断我希望将消息记录到控制台? – sean

+1

这是最好在帖子后面解释它。像我例如错过了标题。无论如何,Amir已经正确回答了。 – dfsq

回答

5

功能fire没有在控制器上曝光。

this.fire = fire;