pipe example in angular
Example 1: command to create custom pipe in angular 6
ng generate pipe personName
Example 2: applying datepipe on interepolating date in html from typescipt
tooltip="{{recentDate | date: 'medium'}}"
Example 3: angular pipes
import {Pipe, PipeTransform} from '@angular/core';
@Pipe ({
name : 'sqrt'
})
export class SqrtPipe implements PipeTransform {
transform(val : number) : number {
return Math.sqrt(val);
}
}
import { SqrtPipe } from './app.sqrt';
declarations: [
SqrtPipe,
],