我正在嘗試向單擊的元素添加一個類,並在用戶單擊其他元素時將其刪除。如何處理我的類中的單擊事件
我有類似
<li ng-repeat='test in tests' >
<a href='' ng-click='pickTest($index, $event)'>{{test.title}}</a>
</li>
JS
$scope.pickTest = function(index, event) {
$(event.target).addClass('blur');
//this works when user clicks one of the <a> tags
//but I want to remove the class if user clicks another <a> tag
};
我該怎麼辦呢?
謝謝!
恐怕這不是 「角辦法」。爲什麼要重新發明輪子並手動操作DOM?這是什麼角度基本上讓你免於做。 – alecxe 2014-09-19 03:10:09
那麼,我沒有經驗使用角度,混合標記與邏輯通常是我試圖避免的東西。 – 2014-09-19 03:21:27