自定义过滤器

myApp.filter( 

'to_trusted', ['$sce', function ($sce) { 

return function (text) {
return $sce.trustAsHtml(text);
}
}]
)

myAppModule.filter("reverse",function(){
                return function(input,uppercase){
                    var out = "";
                    for(var i=0 ; i<input.length; i++){
                        out = input.charAt(i)+out;
                    }
                    if(uppercase){
                        out = out.toUpperCase();
                    }
                    return out;
                }
            });
 <div ng-controller="myAppCtrl">
            name:{{ name }}<br>
            reverse name:{{ name | reverse }}<br>
            reverse&uppercase name:{{ name | reverse:true }}
 </div>

  

  

posted @ 2016-12-30 17:24  小小强学习网  阅读(204)  评论(0编辑  收藏  举报