AngularJS 自定义 filter

来源:互联网 发布:漂流木帆布包 淘宝 编辑:程序博客网 时间:2024/05/16 01:30


问题:后台返回新闻json格式数据,新闻标题被UrlEncode了。

解决:

var app = angular.module('mainApp', []);
app.controller('mainCtrl', function ($scope, $http) {

});


自定义filter

app.filter('decodeURI', function () { //可以注入依赖

    return function (text) {
        return decodeURI(text);
    }

});


使用:

{{h.title | decodeURI }}



原创粉丝点击