Please enable JavaScript.
Coggle requires JavaScript to display documents.
Angular Pipes - Coggle Diagram
Angular Pipes
-
Custom Pipes
Setup
-
Add to Module
declarations: [ ..., ShortenPipe ]
-
e.g FilterPipe
transform( value: any, filterString: string, propName: string ){...}
-
const resultArray = []; for(const item of value){ if( item[propName] === 'filterString' ){ resultArray.push(item); } return resultArray;}
-
Pure vs Impure Pipes
<li *ngFor="let item of users | filter:filterStauts:'status' "> --> add an item to users will not trigger re-render
Set pure to false
@Pipe({ name: 'filter', pure: false })
-
Async Pipe
getSatus = new Promise((resolve, reject) => { setTimeout( resolve('stable'), 2000);})
-