None None - 29 days ago 24
AngularJS Question

ng-click still fires when div is (ng)disabled

Problem is that ng-click works on so event if cancelTicket===false it still fires ng-click.How can i stop that?

<div class="btn-block save-changes padding-10" ng-class="{'gray':cancelTicket===false,'secondary-button':cancelTicket===true}" ng-click="CancelTicket(ticketPin)" ng-disabled="cancelTicket===false" style="display: table;">
<div class="button-container padding3" ng-class="{'pointer':cancelTicket===true}">
<button-spinner promise="cancelPromise"></button-spinner>
<div style="display: inline-block !important;"> @Translator.Translate("CANCEL") </div>
</div>
</div>

Answer

Event is triggered even if the div is disabled.

You can avoid this by using lazy evaluation of expressions like isDisabled || action() so action would not be called if isDisabled is true.

So in your case it will be:

ng-click="cancelTicket===false || CancelTicket(ticketPin)"