<td>{{messagePerson | filter:d.messagePerson }}</td>
$scope.messagePerson = [
{num:0,obj:"所有人"}, {num:1,obj:"男人"}, {num:2,obj:"女人"} ];
$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
Custom filter
It seems $translate can also do it