AngularJS过滤器示例

时间:2014-06-11 13:56:49

标签: angularjs angularjs-directive angularjs-scope angularjs-filter

我正在尝试替换我从json获取的所有网址中的字符串。我认为最好的方法是使用过滤器,尽管可以使用指令完成。不知道哪种方式更正确。

无论如何,我在这里写了一个过滤器,在范围内用https://替换了http://。这就是我得到的地方:

 .filter('secure', function(){
        return function(text) {
            return text.replace(/http/g, 'https');
        };
  });

{{p.link | secure}}

我哪里错了?

0 个答案:

没有答案
相关问题