简体   繁体   中英

Difference between Angular Filters and Angular2 Pipes?

Could somebody explain me conceptual difference between Angular Filters and Angular2 Pipes ? They are built for the same purpose, no? Is there any difference under hood?

<div>{{user.created | dateFormat }}</div>

Even the syntax is quite the same.

Pipe was formerly known as filters in AngularJS 1.x. In Angular 1, we had filter which helped format, sort or transform how data was displayed in our templates. Filters can be used with a binding expression or a directive. In Angular 2, we have a similar feature but renamed to Pipes. This rename was to better align of what the feature does. Coming from the Unix background we | pipe together commands. So in Angular we use the same | pipe character to format our data.

Angular 2 has many new concepts and some of the same concepts from Angular 1.x. Most of the filters from Angular 1.x are retained in Angular 2.0 pipes, in addition to the creation of newer pipes. Angular 1.x and Angular 2 have an equal number of filters to pipes, but there isn't a direct crossover

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM