<html ng-app="ClassementChamps">
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="css/local.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
</head>
<body ng-controller="ChampController as champ">
<!-- search champion -->
<section id="search">
<label>search: <input type="text" ng-model="search"/></label>
<select class="search" ng-model="order">
<option value="score.kills">score.kills</option>
<option value="sex">sex</option>
</select>
</section>
<!-- main-content -->
<section id="main-content">
<ol>
<li ng-repeat="information in champ.infos | filter:search | orderBy:order:true">
<div class="champsCore">
<a href="{{information.page}}">
{{information.champion + ' is a ' + information.sex + ', ' + information.lane}}
</a>
<p ng-repeat="score in information.score">
Score: {{score.kills + ' / ' + score.mort + ' / ' + score.assistances}}.
</p>
</div>
</li>
</ol>
</section>
<!-- footer -->
<section id="footer">
<div id="totalChamps" ng-hide="search">
there is
<strong>{{remaining}}</strong> champs,
<strong>{{adc}}</strong> marksam,
<strong>{{support}}</strong> support.
</p>
</div>
</section>
<script type="text/javascript" src="lib/angular.min.js"></script>
<script type="text/javascript" src="js/app.js"></script>
<script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script>
</body>
</html>var app = angular.module('ClassementChamps', []);
app.controller('ChampController', ['$http', '$scope', 'filterFilter', function($http, $scope, filterFilter){
var champ = this;
champ.infos = [];
$http.get('js/champions.php').success(function(data){
champ.infos = data;
});
$scope.$watch('champ.infos', function(){
$scope.remaining = $scope.champ.infos.length;
}, true);
$scope.$watch('champ.infos', function(){
$scope.adc = filterFilter($scope.champ.infos, {lane:'marksam'}).length;
}, true);
$scope.$watch('champ.infos', function(){
$scope.support = filterFilter($scope.champ.infos, {lane:'support'}).length;
}, true);
}]);
[
{
"champion": "Ashe",
"sex":"female",
"lane":"marksam",
"page":"#Ashe",
"score":[{"kills":"9", "mort":"2", "assistances":"5"}]
},
{
"champion": "Graves",
"sex":"male",
"lane":"marksam",
"page":"#Graves",
"score":[{"kills":"12", "mort":"4", "assistances":"1"}]
},
{
"champion": "Leona",
"sex":"female",
"lane":"support",
"page":"#Leona",
"score":[{"kills":"2", "mort":"0", "assistances":"8"}]
},
{
"champion": "Sona",
"sex":"female",
"lane":"support",
"page":"#Sona",
"score":[{"kills":"1", "mort":"4", "assistances":"17"}]
}
]...
"sex"<span style="
<option ng-click="order = 'sex'">sex</option>
<option ng-click="order = 'score.kills'">kills</option>
"score":[{"kills":"1", "mort":"4", "assistances":"17"}] //look at the json file