Pipes in Angular are used to transform data. It takes integers, strings, arrays, and date as input separated with |
to be converted in the format as required and display the same in the browser.
Below are the built in pipes provied by Angular
To create a custom pipe, we have to import Pipe and Pipe transform from Angular/Core. We can use our custom pipe by importing it in app module.
import { Pipe, PipeTransform } from "@angular/core";
@Pipe({
name: "sqrt"
})
export class SqrtPipe implements PipeTransform {
transform(val: number): number {
return Math.sqrt(val);
}
}
Created 2019-01-23T11:45:03+05:18, updated 2022-01-29T02:34:00+00:00 · History · Edit