2016-04-23 60 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;