Surjeet Bhadauriya Surjeet Bhadauriya - 1 year ago 73
Javascript Question

Is there a drawback of calling more than one function in a ng-click directive?

We are calling two functions in a single ng-click directive, is there any gotcha that we should be aware of?

<button type="button" ng-click="func1(); func2();">Click</button>

We could also call a single function that calls the two function instead:

<button type="button" ng-click="func1()">Click</button>



Aan Aan
Answer Source

No, there is no drawback of calling more than one function inside ng-click, but we have to ignore it most of the time because it's not good practice.

You can achieve this by calling a function inside another function.

<button type="button" ng-click="func1(); func2(); func3();">Click</button>

So here func1 will call first, then func2 and func3.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download