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

Jake Salo
Jake Salo
13,175 Points

AngularJS updating json file according value of input

Following Huston Hedinger's AngularJS course, and the Todo list web application. I am trying to implement the save feature properly, so that when the 'save' button is clicked, it gets the value of the input, and it updates or overwrites the current 'todos.json' file to contain the information which the user changed.

I found a few answers on stack overflow but dont know how to implement them into my code. I am new the angularJS and still very much a novice to it. Thanks.

My code is here on my GitHub if needed. Cheers.

at this file https://github.com/jake6191/todos2/blob/master/scripts/services/data.js

Fix this

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

TO ==>

this.getTodos = function(){
    return $http.get('mock/todos.json')
  };

then use:
dataService.getTodos().then(
  success => {},
  error => {}
);