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 trial

JavaScript AngularJS Basics (1.x) Services in Angular Using Services To Get Data

Problem pulling json file

Ng-repeat is working here on my mark up

angular.module("todoListApp", []) .controller("mainCtrl",function($scope, dataService){ $scope.todos = [
{"name": "clean the shop"},
{"name": "finish angular app"}, {"name": "update css"}, {"name": "finish thank you page"}, {"name": "make queriy calculator responsive"}, {"name": "clean urls"} ]; })

But here it is not working when the array is in a json file

angular.module("todoListApp", []) .controller("mainCtrl",function($scope, dataService){

dataService.getTodos(function(response){ console.log(response.data); $scope.todos = response.data;

    });

}) .service('dataService', function($http){ this.getTodos = function(callback){ $http.get('mock/todos.json') .then(callback) } });

PLEASE HELP!

please re-format your code properly so we can read it easier

change url of geting files with this... this.getTodos = $http.get('scripts/mock/todos.json')

reading files is starting from index.html not from app.js