Address
Darbhanga, Bihar 846004
In Angular, a pipe is a feature that allows you to transform data in your templates. Pipes are used to format, filter, and manipulate data displayed in the view
Angular provides several built-in pipes for common transformations:
**To use a pipe in a template, you use the pipe symbol (|):
<p>{{ today | date }}</p>
Example:
You can chain multiple pipes together in Angular by applying them one after the other in the template
Example:
<p>{{ 'hello world' | uppercase | slice:0:5 }}</p>
*Create the custom pipe:
In na.pipe.ts
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'na',
standalone: true
})
export class NaPipe implements PipeTransform {
transform(value: unknown, …args: unknown[]): unknown {
If(value !== null && value !== undefined && value !== '') {
return value;
} else {
return 'NA';
}
}
}
In html
<p> {{student.state |na}</p>