<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>
Penapis tersuai
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就不用我写了吧。。。
Nampaknya $translate pun boleh buat
Penapis tersuai
Nampaknya $translate pun boleh buat