Created
September 3, 2014 03:19
-
-
Save xavierartot/ae5d28f48ad0f4b6bb93 to your computer and use it in GitHub Desktop.
debug a service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
<html ng-app='app'> | |
<body> | |
<ul ng-controller="appStudent"> | |
<li ng-repeat="student in students"> | |
<a href="/students/view/{{student.id}}">{{$index+1}} - {{student.name}}</a> | |
</li> | |
<button ng-click="addXav()">Add Tom</button> | |
</ul> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script> | |
<script> | |
var myAppModule = angular.module('appStudent', []); | |
myAppModule.controller('StudentCtrl', | |
function($scope){ | |
$scope.students = Students; | |
$scope.addXav = function() { | |
$scope.students.splice(1, 0, {name:'Xavier Thumb', id:'5'}); | |
} | |
}).factory("Students", function(){ | |
var students = {}; | |
students.query = function() { | |
return [ | |
{name: 'Marie Contrariante', id: '1'}, | |
{name: 'Jach Roussel', id: '2'}, | |
{name: 'Laurent Beaulieu', id: '3'}, | |
{name: 'Jean pouille', id: '4'} | |
] | |
} | |
return students; | |
}); | |
</script> | |
</body> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment