<span ng-click="resetbyTask() || filterTask(task.id, $index)">{{ task.total }}</span>
我正在尝试在单个ng-click
之间切换功能,以便第一次点击会运行filterTask()
,再次点击它会运行resetbyTask
答案 0 :(得分:1)
试试这个:
// 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>