How does the ng-click=function() works inside ng-reapeat? Does it created multiple references of scope function?

293 Views Asked by At

I have a ng-repeat over 2000 employees data which is displayed in rows and inside each repeating row/block, I have a function which is passing salary information to directive for some processing. I am binding function on ng-click="calcSalary(emp)". Now my question is will ng-click="calcSalary(emp)" will be created 2000 times? And 2000 different reference will be stored at backend? Will 2000 calcSalary() functions will be created attached to scope? How will be the performance? Is there any way we write only ng-click="calcSalary(emp)" only ones and pass the employee data based on the particular row clicked?

1

There are 1 best solutions below

0
Sajeetharan On

No it does not have any performance issue! Even though you create inside ng-repeat it will be created n times but gets instanciated once and have impact when you click only.

Read about it Angular ng-click event delegation