2014-09-19 142 views
0
<span ng-click="resetbyTask() || filterTask(task.id, $index)">{{ task.total }}</span> 

我想在一個ng-click類函數之間切換,使得第一點擊運行filterTask(),再次單擊時將運行resetbyTaskAngularJS NG-點擊功能之間切換

+0

慣於它是一個很好的IDE a有一個切換功能,你可以有條件地調用子功能? – 2014-09-19 14:41:27

回答

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> 
+0

right edit :)我的心在哪裏.. – meriadec 2014-09-19 14:51:58