0

i have a button with ng-click= which is opening another html, but i want to have two function on my ng-click= "fisrtFunction(will save the row on which is the button which i'm clicking) secondFunction(will open a new html view). The idea is that i want to ignore one more saving on the new added row. Can you give me some ideas. I'm java dev and angular is not my stren

Regards

Christian Benseler
  • 7,907
  • 8
  • 40
  • 71
  • why don't you combine the two functions into a new one in the controller? – Charlie Ng Jan 04 '18 at 18:20
  • 2
    Possible duplicate of [How to add many functions in ONE ng-click?](https://stackoverflow.com/questions/16813945/how-to-add-many-functions-in-one-ng-click) – Cameron637 Jan 04 '18 at 18:20

1 Answers1

0

Why not just execute another function in the body of the other function?

$scope.firstFunction = function(){

   $scope.secondFunction();
}

<button ng-click="firstFunction()"> </button>

You could also pass the function (secondFunction) in as a parameter and call the parameter like a function.

Alternative would be to separate the functions using ; so ng-click="firstFunction(); secondFunction();" but that will eventually become messy the more you add to it.

Adrian
  • 8,271
  • 2
  • 26
  • 43