During a recent project, I had to convert xml data to json and parse it for my app. One issue I encountered was related to the DataSource.get()
function callback in the controller. After converting the xml data using a service, I stored the converted data in $scope.data
. However, when I attempted to parse the data outside of the function and assign different parts to various $scope
elements, I realized that I made an error by not parsing the data inside the function itself. Can anyone explain why the converted data, once assigned to $scope.data
, cannot be used outside of the DataSource.get()
function? As a newcomer to angularjs, I have been unable to find an explanation for this behavior. Any brief clarification would be highly appreciated.
If you need more context, you can refer to my code on plnkr.