0
如何向角度对象添加一个动态的onclick或click事件函数?为角度对象添加动态功能
添加的onclick = {{item.function}}或NG单击= {{item.function}}将无法正常工作
JS
angular
.module('app', [])
.controller('MainController', ['$scope', function($scope) {
$scope.test = function() {
alert(1);
};
$scope.items = {
'item1': {
name: 'Item1',
function: 'test()' // Not calling
}
};
}]);
的Html
<html ng-app="app">
<body ng-controller="MainController">
<ul ng-repeat="item in items">
<li ng-bind="item.name" ng-click="item.function"></li>
</ul>
</body>
</html>
不工作演示 http://codepen.io/anon/pen/jqEKRP