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

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -