Reputation: 383
Is there a way I can get ng-click
to call two functions?
I would like something along the lines of
ng-click ="{search(),match()}"
Instead of how I have it now, which is:
ng-click = "search()"
Upvotes: 38
Views: 70582
Reputation: 185
You can use multiple methods with (click)
separated by ;
(click)="search();match()"
Upvotes: 0
Reputation: 1487
using the ng-click to call function:
ng-click="search()"
using the callback approach if function search () depends on the value returned by function math () in the controller do:
$scope.match() = function(cb){
//do something and return value
var x = 10;
x = x+10;
cb(x)
};
$scope.search() = function(){
//call math function
$scope.match(function(value){
myCalc = value;
});
};
Upvotes: 0
Reputation: 3785
Please use search() one function and add a callback function of match() inside search() function;
ng-click = "search()";
Upvotes: 1
Reputation: 3845
You can call multiple functions with ';'
ng-click="search(); match()"
Upvotes: 86