Possible to pass along a ngclick value to a function?

Issue

Is there a possible solution to increment a variable on each click and pass along to a function? I tried doing something like this but it doesn’t work.

<button ng-click="count++" ng-init="count=1" (click)="assignTasks(count)"> 

Solution

You can both increment and call assignTasks function inside the same ng-click, there is no need for (click)=”assignTasks(count)”

<button ng-init="count=1" ng-click="count = count + 1;assignTasks(count)">Click</button>

Demo

Answered By – NTP

Answer Checked By – Marilyn (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.