0

How we can add 2 function with one ng-click. I try like this : ng-click="Save(); Send();"

but I want to save first then send. Both function having API calls.

Devesh Khosla
  • 15
  • 1
  • 7

2 Answers2

0

call a function like this ng-click="callto2functions()"

$scope.callto2functions =function(){$scope.save();$scope.send();}
Vignesh
  • 1,140
  • 1
  • 9
  • 17
0

the problem is that both your functions return a promise when they are doing api calls (at least they should do that)

but when you chain them they will be fire immediately. since they are promises you can chain them with .then(). this is not possible in the template, so you can build a separate function that handles that case

function saveAndSend() {
    save()
       .then(function(savedData) {
            return send();
        });
Nicolas Gehlert
  • 2,626
  • 18
  • 39