You can call a pipe with multiple arguments by passing them after the pipe name, separated by colons (:). These arguments are forwarded to the transform method of the pipe as additional parameters.
Syntax:
{{ value | pipeName:arg1:arg2:arg3 }}
Run HTML
Steps:
Define the Pipe:
Ensure the pipe's transform method accepts the additional arguments.
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'customPipe' })
export class CustomPipe implements PipeTransform {
transform(value: any, arg1: any, arg2: any, arg3: any): any {
// Use value, arg1, arg2, and arg3 for transformation
return `${value} - ${arg1} - ${arg2} - ${arg3}`;
}
}
Call the Pipe in the Template:
Pass the arguments after the pipe name.
<p>{{ 'Hello' | customPipe:'arg1':'arg2':'arg3' }}</p>
<!-- Output: Hello - arg1 - arg2 - arg3 -->