Extend the handset, such as a currency or number, to a custom channel on angular2

I would call numberPipe on my custom tube. I find this answer

Angular2 use base channel in custom channel

but I this solution does not work for me. I have the error "Could not find handset" BigInteger "

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
 }
}
+4
source share
1 answer

Update

this should be fixed from at least Angular4

original

Known issue with DI and classes that extend other classes

https://github.com/angular/angular/issues/8694

This sets up, you can use composition instead of inheritance:

@Pipe({
  name: "bigInteger"
})
export class BigInteger implements PipeTransform {

  constructor(private currencyPipe:CurrencyPipe) {}

  transform(value: any): string {
     return this.currencyPipe.transform(value);
  }
}
+4
source

Source: https://habr.com/ru/post/1651390/


All Articles