The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Using Pipes to Filter Data

Using Pipes to Filter Data

2:24
Pipes allow you to change data inside of templates without having to worry about changing it in the Controller. Creating a custom Pipe is as simple as giving it a name and a transform function that output what you expect.
Watch this lesson now
Avatar
egghead.io

Pipes allow you to change data inside of templates without having to worry about changing it in the Controller. Creating a custom Pipe is as simple as giving it a name and a transform function that output what you expect.

Avatar
Theuy

Could we improve the code by leveraging the types definitions in the function parameters?

import {Pipe} from "angular2/core";

@Pipe({
    name: "search"
})
export class SearchPipe{
    transform(value:Array, [term:String]){
        return value.filter((item:TodoModel)=> item.title.startsWith(term));
    }
}
In reply to egghead.io
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?