【发布时间】:2014-08-07 06:57:52
【问题描述】:
我已经制定了一个指令,它使用 element.html() 来设置 html。在该 html 代码中,我希望能够在使用该指令的范围内调用函数。像这样:
app.directive('myDirective', ['$rootScope', function ($rootScope) {
return {
restrict: 'A',
link: function(scope, element) {
element.html('<button ng-click="doit()">Does not work</button>');
}
};
}]);
doit() 函数永远不会被调用。
我做了一个 plnkr 来演示一下:
【问题讨论】:
标签: javascript html angularjs