Methods vs pipes

后端 未结 2 1947
迷失自我
迷失自我 2021-01-03 19:55

Is there a difference between using a pipe and a method in template interpolation in an Angular application?

For example:

{{ name.toLowerCase

2条回答
  •  臣服心动
    2021-01-03 20:36

    TL;DR; Don't use functions or methods in the template, use pipes instead.

    A pipe would be called only when input values change. A function or a method would be called on every change detection. Here is a nice article if you want to know more about functions in template.

    Here is a running stackblitz demonstration of method vs pipe.

提交回复
热议问题