Skip to content

Instantly share code, notes, and snippets.

@johnlindquist
Created May 26, 2015 09:57
Show Gist options
  • Save johnlindquist/8b09b43ad89944d8c8fd to your computer and use it in GitHub Desktop.
Save johnlindquist/8b09b43ad89944d8c8fd 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>
</head>
<body ng-controller="BodyController as body">
<ul>
<li ng-repeat="person in body.people">{{person.name}}</li>
</ul>
</body>
</html>
angular.module("workshop", [])
.service("colorService", function ColorService($http){
var colorService = this;
colorService.color = "blue";
colorService.getPeople = function(){
return $http.get("people.json").then(function(result){
return result.data.results;
});
}
})
.controller("BodyController", function(colorService){
var body = this;
body.color = colorService.color;
colorService.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