淡淡烟草味2017-05-15 17:08:59
自訂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就不用我写了吧。。。