Reputation: 61
The thing is i don't want to call them both at the same time like using:
<button ng-click="startCounter(); stopCounter()" >
Is there a way to implement this? Here is my code which is using two buttons.
Here is my Fiddle: https://jsfiddle.net/v3vk3ho0/
Upvotes: 0
Views: 60
Reputation: 2771
although your question is not quite clear, since you do not describe what you actually want or expect to happen, i guess you want to alter the calls from click to click. so you want to call the first function when you click the button first, then the second, then the first again, etc. so here is a solution for that:
<button ng-click="_counterMode = !_counterMode; _counterMode ? startCounter() : stopCounter()" >
what this does is on every click toggling the helper variable _counterMode (from false to true, from true to false, etc) and depending on its value execute function 1 or function 2
Upvotes: 1