我一直在試圖讓角度js爲我訂購我的數據。但唉,它不起作用角度不訂購數據
我從firebase(https://boiling-inferno-4886.firebaseio.com/champion)檢索數據並使用節點js將它發送到控制器。
控制器代碼
var myApp = angular.module('myApp', []);
myApp.controller('AppCtrl', ['$scope', '$http', function($scope, $http) {
// Pulls list of games
$scope.pullGame = function() {
console.log("Here");
$http.get('/getGameData').success(function(response) {
console.log(response);
$scope.championlist = response;
});
};
}]);
然後即時顯示使用所述信息NG-重複
<!DOCTYPE>
<html ng-app="myApp">
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
<title>DevCha</title>
</head>
<body>
<div class="container" ng-controller="AppCtrl">
<input class="form-control" ng-model="game.name">
<button class="btn btn-info" ng-click="pullGame()">Update</button>
<h1>DevCha</h1>
<table class="table">
<thead >
<tr>
<th>Champion Name</th>
<th>Wins</th>
<th>Losses</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="champion in championlist|orderBy: 'name'">
<td>{{champion.name}}</td>
<td>{{champion.wins}}</td>
<td>{{champion.losses}}</td>
</tr>
</tbody>
</table>
</div>
<script src="controllers/controller.js"></script>
</body>
</html>
我已用火力對數據進行排序嘗試,但不工作或者(這是bizarr) 。但是,我很高興,如果任何將整理對我來說(角或火力)
節點JS代碼,該數據推送到角
app.get('/getGameData', function(req, res){
var ref = new Firebase("https://boiling-inferno-4886.firebaseio.com/champion");
ref.once("value", function(snapshot) {
// Success
console.log(JSON.stringify(snapshot.val()));
res.json(snapshot.val());
}, function (errorObject) {
console.log("The read failed: " + errorObject.code);
//callback("Failure", null);
});
});
SAMPLE_DATA - 1:{名稱:「吉姆」,榮獲:10,損失:5},2:{name:'Fred',Win:8,Losses:5} (實際數據可以在firebase鏈接中找到)
tl:dr我需要訂購我的數據, Firebase內置的方法對其進行排序,並以角度|進行排序orderBy但都不工作
究竟是什麼工作?你有錯誤嗎?另外,我建議嘗試使用數據的本地副本來查看'orderBy'是否有效。 – 2015-04-04 05:24:46
你可以粘貼樣本數據嗎? – 2015-04-04 05:25:22
數據位於firebase的鏈接上。沒有錯誤,數據完美顯示,但沒有按我指定的名稱(名稱)排序。 – jromaior 2015-04-04 05:28:12