diff --git a/app/app.js b/app/app.js
index 5169565..97e83a3 100644
--- a/app/app.js
+++ b/app/app.js
@@ -1,6 +1,7 @@
(function () {
'use strict';
+ var app = angular.module('app', ['ngRoute']);
})();
diff --git a/app/details.ctrl.js b/app/details.ctrl.js
index f77a545..194a524 100644
--- a/app/details.ctrl.js
+++ b/app/details.ctrl.js
@@ -3,8 +3,18 @@
angular.module('app').controller('DetailsCtrl', Ctrl);
- function Ctrl() {
+ function Ctrl($http, $routeParams, $location) {
+ var vm = this;
+ vm.item = {};
+ vm.back = back;
+ $http.get('api/tasks/'+$routeParams.id).then(function (resp) {
+ vm.item = resp.data;
+ });
+
+ function back() {
+ $location.path('/list');
+ }
}
})();
diff --git a/app/details.html b/app/details.html
index e69de29..8731a93 100644
--- a/app/details.html
+++ b/app/details.html
@@ -0,0 +1,3 @@
+Title: {{ vm.item.title }}
+Time: {{ vm.item.added | date: "HH:mm"}}
+
diff --git a/app/list.ctrl.js b/app/list.ctrl.js
index 18d73d3..4b8f84f 100644
--- a/app/list.ctrl.js
+++ b/app/list.ctrl.js
@@ -3,8 +3,36 @@
angular.module('app').controller('ListCtrl', Ctrl);
- function Ctrl() {
+ function Ctrl($http, modalService) {
+ var vm = this;
+ vm.items = [{ title: "hello", done: false }];
+ vm.newItem = '';
+ vm.addNew = addNew;
+ vm.removeItem = removeItem;
+
+ pullItems();
+ function pullItems() {
+ $http.get('api/tasks').then(function(resp) {
+ vm.items = resp.data;
+ });
+ };
+
+ function removeItem(id) {
+ modalService.confirm()
+ .then(function() {
+ return $http.delete('api/tasks/'+id);
+ }).then(pullItems);
+ }
+
+ function addNew () {
+ var item = {title:this.newItem, done:false};
+
+ $http.post('api/tasks', item).then(pullItems);
+
+ //this.items.push(item);
+ vm.newItem = '';
+ }
}
})();
diff --git a/app/list.html b/app/list.html
index e69de29..2ed236c 100644
--- a/app/list.html
+++ b/app/list.html
@@ -0,0 +1,9 @@
+