javascript - AngularJS $rootScope not working as expected -


I searched my problem but could not find the solution. I want to be able to cross a variable starting from an http.get to anular as an angle at http.post. The problem is that my retire array is always empty what you want to get my plnkr code Can get on with the comment.

In Javascript, calls are asynchronous You call $ $ http.post $ $ http.get in response Will be:

  $ http.get ('someurl'). Success (work) {var data_array = JSON.parse (data); var tempArray = new Array (); tempArray ['hi'] = 'hi'; $ rootScope.post_array = tempArray; console.log ($ rootScope. post_array); $ http.post ('some-other-url', $ rootScope.post_array) .success (function) {console.log (data);})});    

Comments

Popular posts from this blog

How can I add a seperate action listener to all 14 of my buttons at once that can determine player turn?(java) -

php - Sorting an multidimension array using usort fails -

Simple file compression in C -