Skip to content

Instantly share code, notes, and snippets.

@johnlindquist
Last active August 29, 2015 14:21
Show Gist options
  • Save johnlindquist/d9136a2ff5c95c3a339e to your computer and use it in GitHub Desktop.
Save johnlindquist/d9136a2ff5c95c3a339e to your computer and use it in GitHub Desktop.
<!doctype html>
<html lang="en" ng-app="workshop">
<head>
<meta charset="UTF-8">
<title>AngularJS Jumpstart</title>
<link rel="stylesheet" href="bootstrap.min.css"/>
<script src="angular.js"></script>
<script src="workshop.js"></script>
<script src="people.js"></script>
</head>
<body ng-controller="BodyController as body">
<ul>
<li ng-repeat="person in body.people">{{person.name}}</li>
</ul>
</body>
</html>
angular.module("people", [])
.service("peopleService", function PeopleService($http){
var peopleService = this;
peopleService.getPeople = function(){
return $http.get("people.json").then(function(result){
return result.data.results;
})
};
});
angular.module("workshop", ["people"])
.controller("BodyController", function(peopleService){
var body = this;
peopleService.getPeople().then(function(people){
body.people = people;
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment