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 trialAna Weller
9,310 Points*** SOLVED*** ReferenceError: callback is not defined
I am getting this error in the console:
ReferenceError: callback is not defined
at getTodos (app.js:23)
at new <anonymous> (app.js:10)
at Object.invoke (angular.js:4473)
at extend.instance (angular.js:9093)
at nodeLinkFn (angular.js:8205)
at compositeLinkFn (angular.js:7637)
at compositeLinkFn (angular.js:7641)
at publicLinkFn (angular.js:7512)
at angular.js:1660
at Scope.$eval (angular.js:15916)
Here is the my app.js:
angular.module("todoListApp", [])
.controller('mainCtrl', function($scope, dataService) {
$scope.helloConsole = dataService.helloConsole;
$scope.learningNgChange = function() {
console.log("An input has changed");
};
dataService.getTodos(function(response) {
console.log(response.data);
$scope.todos = response.data;
});
})
.service('dataService', function($http) {
this.helloConsole = function() {
console.log('This is the hello console service!');
};
this.getTodos = function() {
$http.get('mock/todos.json')
.then(callback)
}
});
Any suggestions regarding my code? Thanks,
Ana Weller
9,310 PointsAna Weller
9,310 PointsI realised I had to define callback in the last function
All is working now - thanks!