angular custom pipe that is async

Viewed 92

I am using angular (7+) and have the following custom pipe:

@Pipe({
  name: 'enumtostring'
})
export class EnumtostringPipe implements PipeTransform {

  constructor(private translateEnumService: TranslateenumService) { }

  transform(value: any, type$?: any): any {
    if(value && type$) {
        // this returns an observable of type Observable<string>
        return this.translateEnumService.translateEnumObservable(type$, value);
    }
    return value;    
  }

}

To use this pipe, I always have to use the keyword async too:

{{ KalkulationsTyp.Monat | enumtostring : KalkulationsTyp | async }}

How can I rewrite my pipe so that I can omit the async pipe while using it? Inherit from async pipe? How do I do that?

0 Answers
Related