I would like to call the numberPipe on my custom pipe I find this answer
Angular2 use basic pipe in custom pipe
but I this solution don't work for me. I have an error "The pipe 'bigInteger' could not be found"
import { Pipe, PipeTransform } from "@angular/core"
import { CurrencyPipe } from "@angular/common"
@Pipe({
name: "bigInteger"
})
export class BigInteger extends CurrencyPipe implements PipeTransform {
transform(value: any): string {
return value
}
}
Use ng generate pipe followed by pipe name command to create custom pipes in angular. The command will create a file named custom. pipe. ts along with sample code to implement custom pipe at application root level.
Angular Pipes Multiple custom pipes Having different pipes is a very common case, where each pipe does a different thing. Adding each pipe to each component may become a repetitive code. It is possible to bundle all frequently used pipes in one Module and import that new module in any component needs the pipes.
Maybe obsolete, but this worked for me (Angular 5):
import { Pipe, PipeTransform } from '@angular/core';
import { DecimalPipe } from '@angular/common'
@Pipe({
name: 'bigInteger'
})
export class BigInteger extends DecimalPipe implements PipeTransform {
transform(value: any, args?: any): any {
let result;
result = super.transform(value, args);
//any transformations you need
return result;
}
}
Then you just use it like regular number pipe, but can customize as you wish:
<span>{{someValue | bigInteger : '1.2-2'}}</span>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With