0
<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
  • Wont it be a good idea to have a toggle function and you manage calling the sub functions conditionaly? Commented Sep 19, 2014 at 14:41

1 Answer 1

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.