我一直在试图让角度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