【发布时间】:2014-10-10 19:46:28
【问题描述】:
我正在尝试将我的状态值从数字更改为“文本”
我想知道如何解决它,我做错了什么?提前谢谢你
<table>
<tr ng-repeat="x in Id">
<td>{{ x.id }}</td>
<td>{{ x.status | status}}</td>
</tr>
</table>
当我写 |状态
var app = angular.module('customersController', []);
function customersController($scope, $http) {
$http.get("localhost")
.success(function (response) {
$scope.Id = response;
});
app.filter('status', function () {
return function (input) {
var statu;
switch (input) {
case 10:
statu = 'Bronze';
break;
case 20:
statu = 'Silver';
break;
case 30:
statu = 'Gold';
break;
case 40:
statu = 'Elite';
break;
}
return statu;
};
});
【问题讨论】:
-
不应该是
return statu而不是点吗? -
对不起,我错过了,但仍然无法正常工作
-
打开控制台,有什么错误吗?
-
response中返回的内容是什么? -
没有返回响应
标签: angularjs angularjs-filter