我有一個標誌按鈕,當用戶點擊時,標誌着討論,之後標誌按鈕被文本'成功標誌'取代。目前,我在點擊標誌按鈕後無法禁用ng-click。 ng-click對於文本'已成功標記'仍然存在,我想阻止點擊此文本以防止在標記相同討論時發生錯誤。如何在ng-if ng-switch語句內點擊後禁用ng-click?
HTML:
<div ng-if="canFlag(discussion)">
<div ng-switch="isFlagging"
ng-disabled="button_clicked"
ng-click="do_something()"
id="flag{{discussion.id}}"
title="{{'flag as inappropriate'}}"
robo-confirm="{'Are you sure you want to flag this?'}"
class="feedActionBtn">
<i ng-switch-when="false"
class="icon-flag"></i>
<div ng-switch-when="true"
translate translate-comment="success message">
Successfully flagged</div>
</div>
</div>
JS:
$scope.isFlagging = false;
$scope.button_clicked = false;
$scope.do_something = function() {
$scope.button_clicked = true;
this.isFlagging = true;
}
通過添加惰性評估或通過防止傳播,我也許能阻斷do_something()方法被調用,但我我也希望鼠標光標仍然是一個指針,而不是變成「點擊鏈接」鼠標圖標,這可能嗎?
看起來像鼠標按鈕圖像是一個css問題,我修正了
我也試過只是在ng-switch-when語句中添加ng-click語句,如下圖,但點擊後isFlagging仍然是false我沒有得到成功的文本:
<div ng-switch-when="false"
ng-click="do_something()"
id="flag{{discussion.id}}"
title="{{'flag as inappropriate'}}"
robo-confirm="{'Are you sure you want to flag this?'}"
class="feedActionBtn">
<i class="icon-flag"></i>
</div>
的[上所有類型的元件的應用的特定條件下禁用納克單擊]可能的複製(http://stackoverflow.com/questions/23194477/disable-ng-click-on-certain-conditions-of-application-for-all-types-of-element) – Luca
以前試過,不行的 – chonglawr