InterviewSolution
| 1. |
How do you create a custom pipe in Angular 4? |
|
Answer» Here’s an example of creating a pipe which reverses the order of letter WITHIN a string. Following is the code to be found in the reverse-str.pipe.ts file. IMPORT { Pipe, PipeTransform } from '@angular/core'; Now, including the custom pipe as a declaration within the Angular app module: import { BrowserModule } from '@angular/platform-browser'; Here’s how to use the custom pipe in your TEMPLATES: {{ user.name | reverseStr }} |
|