23

ng-change = "ControllerName.functionName()"

here I want to add one more function to that. How can I do that ?

Thanks in advance.

2

5 Answers 5

37

This should do the trick:

ng-change = "ControllerName.functionName(); ControllerName.anotherFunction();"
7

Why not rather group the functions in the controller inside another function?

function onChangeGroup(){
 doStuff();
 doMoreStuff();
}

<input ng-change="ControllerName.onChangeGroup()"/>

Regards

1
  • 3
    IMHO, this can obscure what's happening a little bit; it's useful to be able to read through the template and know what sort of actions are triggered by changes on each model. That being said, there is of course a limit; I would mayyyybe allow up to three function calls in ngChange without wrapping them in another function, and probably only if they had short, descriptive names. Anything more than three and I'd definitely want to wrap it in a new scope function Dec 14, 2017 at 16:46
7

This is working properly but one controller in both function.

ng-change = "function1();function2();"
6

for angular version 1.* : ng-change = "function1();function2();"

for angular version 2.* or more: (change)= "function1();function2();"

3

You just need to add another function in the same double quotes.

ng-change = "ControllerName.functionFirst(); ControllerName.functionSecond();"

You can use ng-change for multi expression by adding semicolon ; after each expression

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.