具有异步功能的Angular自定义管道

时间:2018-03-13 15:39:35

标签: angular

我正在创建自定义管道culture,它会执行一些异步localdb / http请求以从服务器返回数据。我们来看看以下内容:

{{ 'hello' | culture:'es-mx' }}

我需要这是Hola,但我希望将其呈现为asyncPipeTransform接口为我提供了transform(value: any, ...args: any[]): any接口。我该如何实现它async?这是可行的吗?

this question中的答案,例如建议async管道,然后是filter/sort来实现这一点,以主动监听数组更改和过滤,但这似乎性能很重因为我的应用程序中有很多管道。

我想实现这样的事情:

 transform(value: any, ...args: any[]): any {

        operation.subscribe(result => {
            // set the pipe value from here...
        })


 }

0 个答案:

没有答案
相关问题