ngClick事件未在Angular 1.5.5组件中触发

时间:2016-04-23 09:16:33

标签: angularjs angularjs-directive

为什么不点击下面模板中描述的按钮按预期工作? This blog post does the exact same thing

'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>"
});

编辑:为问题添加了更多清晰度

1 个答案:

答案 0 :(得分:5)

函数fire未在控制器上公开。

this.fire = fire;