Angular: ng-repeat scope - 14410993
http://angularjs.org/
by James Humigas
HTML
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<div ng-controller="MyCtrl">
<table class="table striped highlight">
<thead class="light-blue darken-4">
<tr>
<th></th>
<th>Ultimate</th>
<th>Tchoukball</th>
<th>Football</th>
<th>Volleyball</th>
<th>Handball</th>
<th>Basketball</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="schedule in schedules">
<td>{{schedule.HEURE_DEBUT_MAT}}</td>
<td>{{myvs(schedule)}}</td>
<td>{{myvs(schedule)}}</td>
<td>{{myvs(schedule)}}</td>
<td>{{myvs(schedule)}}</td>
<td>{{myvs(schedule)}}</td>
<td>{{myvs(schedule)}}</td>
</tr>
</tbody>
</table>
</div>
JavaScript
var myApp = angular.module('myApp', []);
//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});
function MyCtrl($scope) {
$scope.schedules = [{
"NOM_EQU1": "Les Schnitzels",
"NOM_EQU2": "Les Patrons",
"NOM_SPO": "Ultimate",
"HEURE_DEBUT_MAT": "09:00"
}, {
"NOM_EQU1": null,
"NOM_EQU2": "Koh Lanta",
"NOM_SPO": "Tchoukball",
"HEURE_DEBUT_MAT": "09:10"
}];
$scope.myvs = function(schedule) {
if (schedule.NOM_EQU1 != null) {
return schedule.NOM_EQU1 + " vs " + schedule.NOM_EQU2
}
return "-"
}
}