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 trialMahmod Issa
11,745 PointsConsole Errors
My console is showing some errors.
TypeError: dataService.getTodos is not a function XMLHttpRequest cannot load file:///C:/wamp/www/projetos/angular/mock/todos.json. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
Please help.
angular.module('todoListApp', [])
.controller('mainCtrl', function($scope, dataService){
$scope.helloConsole = dataService.helloConsole;
$scope.learningNgChange= function(){
console.log('Helloo There, this is hello world controller function, in the mainCtrl');
};
$scope.todos = dataService.getTodos();
})
.service('dataService', function($http){
this.helloConsole = function(){
console.log("This is the hello console service!");
};
this.getTodos = $http.get('mock/todos.json')
.then(function(response){
console.log(response.data);
return response.data;
})
});
1 Answer
Chris Shaw
26,676 PointsHi Mahmod,
This error is appearing because you're attempting to run Angular from a file:///
path which isn't supported when using the $http
service, instead you need to run it from localhost which you can do by using the below URL given WAMP is running.
http://localhost/projetos/angular
Hope that helps.