6

What Is Angular Impure Pipe?

What Is Impure Pipe?
Angular executes an impure pipe during every component change detection cycle. An impure pipe is called often, as often as every keystroke or mouse-move.

If you want to make a pipe impure that time you will allow the setting pure flag to false.
@Pipe({
  name: 'currency',
  pure:false
})

The example for impure pipe –
import { PipePipeTransform } from '@angular/core';

@Pipe({
  name: 'currency',
  pure:false
})
export class CurrencyPipe implements PipeTransform {

  transform(valueanyargs?: any): any {
    if (!value) {
      return '1.00';
    }

    return value;
  }
}

For more detail kindly refer the -
https://www.code-sample.com/2018/05/angular-5-6-7-pipes-decorator.html
ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..

My Tech Blog - https://www.code-sample.com/
My Books - Book 1 and Book 2

What Is Angular Impure Pipe? What Is Angular Impure Pipe? Reviewed by Anil Singh on 2:54 AM Rating: (5)
www.code-sample.com/. Powered by Blogger.
^