Skip to content

Commit cbb9134

Browse files
committed
Updated the Angular app to use the API data
1 parent 446b76e commit cbb9134

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

public/scripts/controllers/main.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
angular.module('todoListApp')
44
.controller('mainCtrl', function($scope, dataService){
5-
5+
66
dataService.getTodos(function(response){
7-
var todos = response.data;
7+
var todos = response.data.todos;
88
$scope.todos = todos;
99
});
10-
10+
1111
$scope.addTodo = function() {
1212
$scope.todos.unshift({name: "This is a new todo.",
1313
completed: false});
1414
};
15-
16-
})
15+
16+
})

public/scripts/services/data.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
angular.module('todoListApp')
44
.service('dataService', function($http) {
55
this.getTodos = function(cb) {
6-
$http.get('/mock/todos.json').then(cb);
6+
$http.get('/api/todos').then(cb);
77
};
8-
8+
99
this.deleteTodo = function(todo) {
1010
console.log("I deleted the " + todo.name + " todo!");
1111
};
12-
12+
1313
this.saveTodos = function(todos) {
1414
console.log("I saved " + todos.length + " todos!");
1515
};
16-
16+
1717
});

0 commit comments

Comments
 (0)