1// In Angular
2// Html
3<p>{{myDate | date: 'dd-MM-yyyy'}}</p>
4// Typescript
5myDate: Date = new Date();
1<p>{{name | lowercase}}</p>// Convert to LowerCase
2<p>{{name | uppercase}}</p> // Convert to UpperCase
3<p>{{name | titlecase}}</p> // Convert to TitleCase
4<p>{{birthday | date}}</p> // Convert to Date
5<p>{{value | currency: ERU}}</p> // Convert value in pounds
1//component.ts file:
2
3import {Pipe, PipeTransform} from '@angular/core';
4@Pipe ({
5 name : 'sqrt'
6})
7export class SqrtPipe implements PipeTransform {
8 transform(val : number) : number {
9 return Math.sqrt(val);
10 }
11}
12
13//import SqrtPipe inside your module.ts ,
14import { SqrtPipe } from './app.sqrt';
15declarations: [
16 SqrtPipe,
17],
18
19//then you can use this pipe in component.html file.
20// <h2>Square root of 625 is: {{625 | sqrt}}</h2>