Created
May 26, 2015 09:57
-
-
Save johnlindquist/8b09b43ad89944d8c8fd to your computer and use it in GitHub Desktop.
This file contains hidden or 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> | |
<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> |
This file contains hidden or 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
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