0 votes
in Angular by

What is a parameterized pipe?

1 Answer

0 votes
by

A pipe can accept any number of optional parameters to fine-tune its output. The parameterized pipe can be created by declaring the pipe name with a colon ( : ) and then the parameter value. If the pipe accepts multiple parameters, separate the values with colons. Let's take a birthday example with a particular format(dd/MM/yyyy):

import { Component } from '@angular/core';

    @Component({

      selector: 'app-birthday',

      template: `<p>Birthday is {{ birthday | date:'dd/MM/yyyy'}}</p>` // 18/06/1987

    })

    export class BirthdayComponent {

      birthday = new Date(1987, 6, 18);

    }

Note: The parameter value can be any valid template expression, such as a string literal or a component property.

Related questions

0 votes
asked Dec 16, 2023 in Angular by AdilsonLima
0 votes
asked Jul 11, 2023 in Angular by rahuljain1
...