Skip to content

Instantly share code, notes, and snippets.

@xavierartot
Created September 3, 2014 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xavierartot/ae5d28f48ad0f4b6bb93 to your computer and use it in GitHub Desktop.
Save xavierartot/ae5d28f48ad0f4b6bb93 to your computer and use it in GitHub Desktop.
debug a service
<!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