Angular JS | what to pass in ng-click ternary operator to do nothing

I am trying to enable ng-click based on a condition using ternary operator (?:)


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

Why not:


$scope.Update = function(){
    // do something

It will be easier to: 1.Debug. 2.Read your code. 3.Add conditions to your code in the feature. 4.Clean your htmls.


You can do it like this instead:

ng-click="hasPermission && Update()"

Why don't you write just

ng-click="hasPermission && Update()"

It will check weather hasPermission is not false/undefined/null it will call the update()


Just change the value of $scope.has in above demo & see.

Terrnary operator in ng-click you should write like this

<div ng-click="hasPermission ? Update() : DontUpdate()">

Need Your Help

what does android getIntrinsicHeight and getIntrinsicWidth mean?

android drawable

Hi I am confused by the two methods from Android Drawable class

How can I generate UUID in C#

c# .net visual-studio-2008 com uuid

I am creating an .idl file programmatically. How do I create UUIDs for the interfaces and Methods Programmatically.