angular.js - angular converts 0 1 2 to everyone man woman
某草草
某草草 2017-05-15 17:06:59
0
3
627
 <td>{{messagePerson | filter:d.messagePerson }}</td>

$scope.messagePerson = [

                        {num:0,obj:"所有人"},
                        {num:1,obj:"男人"},
                        {num:2,obj:"女人"}
             ];
某草草
某草草

reply all(3)
曾经蜡笔没有小新
$scope.sexObj= {
 0:"所有人",
 1:"男人",
 2:"女人"
}

<td>{{ sexObj[messagePerson] }}</td>
淡淡烟草味

Custom filter

angular.module('myApp').filter('myFilter'[myFilter])
function myFilter(){
    switch(input){
        case '0':
            return "所有人";
            break;
        case '1':
            return "男人";
            break;
        case '2':
            return "女人";
            break;
        default:
            break;
    }
}
 $scope.message=[
         {num:0},
         {num:1},
         {num:2},
    
    ]
    
    <tr ng-repeat="item in message">
        <td>{{ item.num|myFilter }}</td>
     </tr>
     
     //最后在controller里面依赖这个filter就不用我写了吧。。。
某草草

It seems $translate can also do it

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template