use custom pipe in component code example
Example: angular create custom pipe
// Create a custom pipe
// First run the command:
ng g pipe pipes/yourPipeName
// Then import and declare on your module
import { YourPipeNamePipe } from '../../pipes/your-pipe-name.pipe';
@NgModule({
imports: [
...
],
declarations: [ YourPipeNamePipe ]
})
// On your-pipe-name.pipe.ts
@Pipe({
name: 'yourPipe'
})
...
transform(value: any, ...args: any[]): any {
return "converted test message";
}
// On your xxx.component.html
{{"test" | yourPipe}} // prints "converted test message"