'Impure pipes instead of template function in angular

I know using template function is not a good idea in angular. So in the projects which I have worked I was using pipes. But now I read an article which tells that we should use pure pipes to avoid change detection. So my question is, if we set pure as false and use that pipe instead of template function, does this both have the same change detection effect ? Only pure pipes should be used in this case? And what about a getter function ? Does getter functions if we use in angular template, will not run change detection as normal template function ? Please some one help me with this, and if this is a stupid question, please forgive me. Thanks in advance



Solution 1:[1]

Impure Pipes

An impure pipe will be called on every change detection cycle, the same as for a template function.

https://angular.io/guide/pipes

Impure pipes are called whenever change detection runs for a component, which could be as often as every few milliseconds.

You should consider alternatives like preloading data, or if you really want to use a pipe, implement caching within it.

Getters

Getters will be called on every change detection cycle.

Refer to stackblitz where you can click the Increment button to cause change detection, and observe the console where you will see the console log from the name getter.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 wlf