问题
<span ng-click="resetbyTask() || filterTask(task.id, $index)">{{ task.total }}</span>
I am trying to toggle between fucntions in a single ng-click so that the first click will run filterTask() and when clicked again it will run resetbyTask
回答1:
Try this :
// controller
var called = false;
$scope.toggle = function (taskId, index) {
if (called) { called = false; return $scope.resetbyTask(); }
$scope.filterTask(taskId, index);
called = true;
}
HTML :
<span ng-click="toggle(task.id, $index)">{{ task.total }}</span>
来源:https://stackoverflow.com/questions/25936286/angularjs-ng-click-toggling-between-functions