AngularJS set ng-click function with scope variables within ng-repeat
问题 I would like to assign different functions to ng-click within ng-repeat: <button ng-repeat="button in notification.buttons" ng-click="button.fn"> {{button.label}} </button> Controllers: app.controller('MainCtrl', ['$scope', function($scope){ $scope.notification = { ctrl: 'logout', text: 'Logout?', buttons: [ {label:'Yes', fn: 'logout()'}, {label:'No', fn: 'cancel()'}, ], }; }]); app.controller('logout', ['$scope', function($scope){ $scope.logout = function(){ alert('logout'); }; $scope.cancel