Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why do I see the method executed many times?
Message
De
29/05/2015 10:42:23
 
 
Information générale
Forum:
Javascript
Catégorie:
Autre
Divers
Thread ID:
01620290
Message ID:
01620331
Vues:
31
>>>I put the breakpoint in the getFilteredTotal method and I can see it executed several times (when I got tired I removed the breakpoint). I think I've seen similar issues before.
>>>
>>>Why would angularJs JavaScript execute this code multiple times when it's in a table? It is not in the ng-repeat directive, right? As the tr tag is closed already.
>>
>>Same problem as in my last reply: It's probably being evaluated on every $digest cycle. Solution is the same.
>
>I am going to try to re-design it but if you can elaborate with a sample, it will be great.
>
>Thanks again.

There's an example in the documentation: https://docs.angularjs.org/guide/filter under 'Using filters in controllers,services and directives'

Snip from the docs :
" However, using a filter in a view template will reevaluate the filter on every digest, which can be costly if the array is big.

The example below therefore calls the filter directly in the controller. By this, the controller is able to call the filter only when needed (e.g. when the data is loaded from the backend or the filter expression is changed)."
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform