I am trying to enable ng-click based on a condition using ternary operator (?:)
ng-click="hasPermission?Update():...."
In last parameter of ternary operator what can I pass so that nothing would happen.
Also, I don't want to create any dummy function in my JS or to write any irrelevant condition as 1=1
angular.noop() was provided to address your scenario:
<div ng-click="hasPermission ? Update() : angular.noop()">
noop() is a function that peforms no operations.
Documention Here
You can do it like this instead:
ng-click="hasPermission && Update()"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With