AngularJS过滤器示例

AngularJS过滤器示例,angularjs,angularjs-directive,angularjs-scope,angularjs-filter,Angularjs,Angularjs Directive,Angularjs Scope,Angularjs Filter,我试图替换从json获得的所有URL中的字符串。我认为最好的方法是使用过滤器,尽管可以使用指令。不知道哪条路更正确 无论如何,我被困在这里写一个过滤器,在作用域中将http://替换为https://了。以下是我得到的信息: .filter('secure', function(){ return function(text) { return text.replace(/http/g, 'https'); }; }); {{p.l

我试图替换从json获得的所有URL中的字符串。我认为最好的方法是使用过滤器,尽管可以使用指令。不知道哪条路更正确

无论如何,我被困在这里写一个过滤器,在作用域中将http://替换为https://了。以下是我得到的信息:

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

{{p.link | secure}}

我哪里错了?

怎么了?您是否遇到错误,或者筛选器没有执行任何操作?工作正常:。那么你的问题是什么呢?哈哈,在RequireJS中没有把它作为依赖项。