Skip to content

Instantly share code, notes, and snippets.

@xavierartot
Last active August 29, 2015 14:06
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/be943bd8f1206fbbad84 to your computer and use it in GitHub Desktop.
Save xavierartot/be943bd8f1206fbbad84 to your computer and use it in GitHub Desktop.
debug a service
<!DOCTYPE html>
<html ng-app='appStudent'>
<body>
<ul ng-controller="StudentCtrl">
<p>{{student.name}}</p>
<li ng-repeat="student in students">
<a href="/students/view/{{student.id}}">{{$index+1}} - {{student.name}}</a>
</li>
</ul>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script>
<script>
var appStudent= angular.module('appStudent', []);
appStudent.controller('StudentCtrl',
function( $scope, Students){
$scope.students = Students;
});
appStudent.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