angular - 异步的角度自定义管道
问题描述
我正在使用角度(7+)并具有以下自定义管道:
@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;
}
}
要使用这个管道,我也必须使用关键字async:
{{ KalkulationsTyp.Monat | enumtostring : KalkulationsTyp | async }}
如何重写我的管道,以便在使用时可以省略异步管道?从异步管道继承?我怎么做?
解决方案
推荐阅读
- c# - C# - 将 XML 元素转换为连接字符串中的键值对
- android - Flutter Firebase - Release APK 与 Debug APK 不同
- mongodb - _id 找不到子文档
- javascript - 如何输入我的代码客户端日期和时间?
- apache-spark - 在 Pyspark Structured Streaming 中,如何在写入 Kafka 之前丢弃已经生成的输出?
- python - 为什么在没有 sudo 的情况下使用 sudo 安装 netfilterqueue 不起作用 python 找到了模块
- c - 创建一个指向存储在另一个地址的地址的指针
- swift - 当用户切换到暗模式时,无法更新 UINavigationBar tintColor
- html - 如何对响应式导航栏进行排序
- python - 如何为数据框中的每一列创建一个 csv 文件?