我試圖將我的狀態值從數字更改爲'文本'我的過濾器不工作
我想知道我該如何解決它,以及我做錯了什麼?預先感謝您
<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;
};
});
它不應該是'返回statu'而不是點嗎? – lucuma 2014-10-10 19:48:12
對不起,我錯過了,但仍然不起作用 – adam 2014-10-10 19:50:00
打開控制檯,有什麼錯誤? – tymeJV 2014-10-10 19:51:47