3

Is there any way to bind multiple functions to ng-click? How to do that? If not possible, what is the alternative way?

<input type="radio" name="op1" ng-click="chkVal()" ng-value="">

I have two functions. chkVal() and deActivate(). I want to check the value and disable the radio with one click.

It may achieve with one function, but I want to know how to use multiple functions.

Thank you

2 Answers 2

3

You can call multiple functions in an ng-click by doing

<input type="radio" name="op1" ng-click="chkVal1();chkVal2();etc();" ng-value="">
Sign up to request clarification or add additional context in comments.

Comments

1

I personally prefer to not stack functions inside an html Attribute, my suggestion is to call one function that will call the other functions you need to keep your HTML tag clear and readable. like :

<input type="radio" name="op1" ng-click="chkVal()" ng-value="">

and inside your controller :

$scope.chkVal() = function(){
   callFunction1();
   callFunction2();
   callFunction3();
         .
         .
         .
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.