Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call multiple functions on ng-change in angularJS?

Tags:

ng-change = "ControllerName.functionName()"

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

Thanks in advance.

like image 697
Suhas V Avatar asked Sep 26 '16 08:09

Suhas V


People also ask

Can you call two functions on click angular?

Yes, you can call two JS Function on one onClick.

How do you use NG on change?

The ng-change event is triggered at every change in the value. It will not wait until all changes are made, or when the input field loses focus. The ng-change event is only triggered if there is a actual change in the input value, and not if the change was made from a JavaScript.

What is Ng Onchange?

ngOnChanges(): "A lifecycle hook that is called when any data-bound property of a directive changes. Define an ngOnChanges() method to handle the changes." We use this lifecycle hook to respond to changes to our @Input() variables.


2 Answers

This should do the trick:

ng-change = "ControllerName.functionName(); ControllerName.anotherFunction();" 
like image 127
Stefan Rein Avatar answered Oct 03 '22 11:10

Stefan Rein


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

function onChangeGroup(){  doStuff();  doMoreStuff(); }  <input ng-change="ControllerName.onChangeGroup()"/> 

Regards

like image 29
frikkievb Avatar answered Oct 03 '22 09:10

frikkievb