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) -

c# - passing input text from view to contoller with FacebookContext using Facebook app -

Calling a C++ function from C# by passing a string with variable size to it -