playing with angularjs

This commit is contained in:
Erik Forkalsrud 2014-08-29 13:12:53 -07:00
parent 14326b0fce
commit cca99e23b7
2 changed files with 27 additions and 0 deletions

13
src/main/webapp/album.js Normal file
View file

@ -0,0 +1,13 @@
var album = angular.module("album", [ ]);
album.controller("AlbumController", ["$http", "$log", function($http, $log) {
var alb = this;
this.items = [ ];
this.update = function() {
$log.info("updating...");
$http.get("/photo/album/Downloads.json").success(function(data) {
alb.items = data.contents;
});
}
}]);

14
src/main/webapp/ang.html Normal file
View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html ng-app="album">
<head>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.js"></script>
<script src="album.js"></script>
</head>
<body ng-controller="AlbumController as album">
<h1>Album</h1>
<form><input type="button" ng-click="album.update()" value="Update" /></form>
<div ng-repeat="item in album.items">
<img ng-src="/photo/album{{ item.path }}?size=250"/>
</div>
</body>
</html>