Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAlessandro Muraro
15,457 PointsAll my todos are gone
I'm trying to follow along, and it seems to me all has been followed correctly, but clearly I must be missing something.
Right now, I see no todo items, although the ng-repeat is working
My code is as follows:
angular.module("todoListApp", [])
.controller('mainController', function($scope, dataService){
dataService.getTodos(function(response){
console.log(response.data);
$scope.todos = response;
});
})
.service('dataService', function($http) {
this.getTodos = function(callback){
$http.get('js/mock/todos.json')
.then(callback)
}
})
;
My todo list shows five empty rows.
Any help is appreciated, thanks!
2 Answers
rvandaalen
24,090 PointsHI
Try adding .data to the response your assigning to $scope.todos
dataService.getTodos(function(response){
console.log(response.data);
$scope.todos = response.data;
});
That should probably fix it.
Alessandro Muraro
15,457 PointsThanks, that did the trick!