Issue
Does angular pipe memoization remember values for parameter sets or just check if the params has changed and then recalculate?
For example, suppose we have a pipe which transforms a number into ”even“ or ”odd”. Then, this number will be changed from 0 to 1, back to 0, then 1, then 0, …
Will angular ”calculate” the string each time, i.e. call the function each time, or will it have the values remembered and therefore just print the known value?
Solution
It checks if the params has changed and then recalculate. So for your example, it will trigger the transform function every time. But if for example, it receives "0 0 0 0", it will ”calculate” it only once. In order for it to work the pipe has to be pure ( it's pure by default ). Corresponding docs can be found here.
Answered By - alexdefender93
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.