Angular Binding To A Function On The View Results To Infinite Calls To The Data Service
I'm trying to bind a src attribute of images inside an ngFor directive that looks like this:
Solution 1:
I don't think this is related to *ngFor
. If you bind from the view to a function then this function is called every time Angular runs change detection which is by default on every event that happens on your page.
In devMode
(in contrary to prodMode
) change detection even runs twice for each event.
Store the result in a property and bind to that property instead or at least return a cached result from your function on subsequent calls if the input parameter (id:string
) hasn't changed since the last call.
For example like shown in https://stackoverflow.com/a/36291681/217408
Post a Comment for "Angular Binding To A Function On The View Results To Infinite Calls To The Data Service"