有没有办法来更新异步数据过滤器 [英] is there a way to update filter with async data

查看:135
本文介绍了有没有办法来更新异步数据过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建下一个角过滤器:

App.filter('cur2symbol', ['CurrenciesService', function (CurrenciesService) {
        return function (input, iso) {
            input = input || '';
            iso = iso || 'ILS';
            var symbol= CurrenciesService.getCurrencySymbolByIso(iso);

            return symbol+input;
        };
    }])

此过滤器的意思是让货币ISO code和转换是为〔实施例符号:结果
接下来的code {{200 | cur2symbol:ILS}} 将输出₪200

我的问题是,在 CurrenciesService 服务是异步的,所以过滤器工作不正常。
只有过滤服务的负荷越来越符号后。

My problem is that the CurrenciesService service is Async, so the filter is not working correctly. only filtering After the the service load are getting the symbol.

我想到下一个解决方案:结果
 1.不要使用过滤器,使用指令,使符号模型,所以加载的数据什么时候会更新。问题是,它会造成太多的绑定,我使用的货币符号,在许多地方!结果
 2.寻找一种方法来运行服务加载后再次过滤器(我不知道,如果它甚至有可能)

I thought about the next solutions:
1. Instead of using filter, using directive and making the symbol a Model, so it will update when the data is loaded. the problem is it will create too much bindings, I am using the currency symbol in many places!.
2. finding a way to run the filter again after the service has loaded (I don't know if it's even possible)

我会很高兴的任何想法解决方案

I will be glad for any ideas solution

推荐答案

如果有人遇到过这个问题,我曾在这里找到了答案:

if someone encountered this issue, I had found the answer here:

<一个href=\"http://stackoverflow.com/questions/19046641/asynchronously-initialize-angularjs-filter\">Asynchronously初始化AngularJS过滤器

这篇关于有没有办法来更新异步数据过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆