23

ng-change = "ControllerName.functionName()"

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

Thanks in advance.

smnbbrv
  • 23,502
  • 9
  • 78
  • 109
Suhas V
  • 231
  • 1
  • 2
  • 7

5 Answers5

37

This should do the trick:

ng-change = "ControllerName.functionName(); ControllerName.anotherFunction();"
Stefan Rein
  • 8,084
  • 3
  • 37
  • 37
7

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

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

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

Regards

frikkievb
  • 481
  • 3
  • 11
  • 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 – Ken Bellows Dec 14 '17 at 16:46
7

This is working properly but one controller in both function.

ng-change = "function1();function2();"
Ken Bellows
  • 6,711
  • 13
  • 50
  • 78
pawan sen
  • 716
  • 5
  • 14
6

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

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

Ferdous Wahid
  • 3,227
  • 5
  • 27
  • 28
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

Ayaz Ali Shah
  • 3,453
  • 9
  • 36
  • 68