AngularJS ng-单击功能之间的切换

时间:2014-09-19 14:28:52

标签: angularjs angularjs-scope

<span ng-click="resetbyTask() || filterTask(task.id, $index)">{{ task.total }}</span>

我正在尝试在单个ng-click之间切换功能,以便第一次点击会运行filterTask(),再次点击它会运行resetbyTask

1 个答案:

答案 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>