过滤一些航程类型或者其他类型的写法

(function () {
    //航线
    appModule.filter('lineFilter', function () {
        return function (value, splitStr) {
            if (!value)
                return value;
            var result = value.substr(0, 3) + splitStr + value.substr(3, 3);
            //console.log(result);
            return result;
        };
    })
    //行程类型过滤
    .filter('tripTypeFilter', function () {
        return function (tripType) {
            var result = '';
            if (!tripType)
                return result;
            switch (tripType) {
                case 1:
                    result = '单程';
                    break;
                case 2:
                    result = '往返';
                    break;
                default:
                    result = '未定义';
            }
            return result;
        };
    })
    //流量类型过滤
    .filter('flowTypeFilter', function () {
        return function (flowType) {
            var result = '';
            if (!flowType)
                return result;
            switch (flowType) {
                case 0:
                    result = '实时';
                    break;
                case 1:
                    result = '缓存';
                    break;
                case -1:
                    result = '全部';
                    break;
                default:
                    result = '未定义';
            }
            return result;
        };
    });
})();

  

posted @ 2017-04-21 09:44  代码小白一枚  阅读(432)  评论(0编辑  收藏  举报