ebakunin
ebakunin

Reputation: 3801

In Angular, why use a pipe instead of a native JavaScript function?

What is the advantage of using an Angular pipe when a comparable native JavaScript function exists? For example:

<input type="text" [value]="foo | uppercase">

vs.

<input type="text" [value]="foo.toUpperCase()">

Upvotes: 0

Views: 169

Answers (1)

david valentino
david valentino

Reputation: 936

pipe decorator @Pipe has pure option which is if false will listen to your changes of the variable passed in and rerun the pipe

With pure: false the pipe is evaluated each time Angular runs change detection.

also with toUpperCase() supose view will not evaluate your ts variable again

Upvotes: 1

Related Questions