This is located in the html file. It works so far, but the issue is that I want to use AngularJS. Now, while Angular CAN use the variables, i cannot load the whole thing into a variable so I can use a for each loop. This seems to be related to the "$Scope", which is usually located in the .js file.

The problem is that I cannot load code from other pages into a .js file. Every example of Angular only shows stuff like this:

2 Answers
2

As Kris mentions, you can use the $resource service to interact with the server, but I get the impression you are beginning your journey with Angular - I was there last week - so I recommend to start experimenting directly with the $http service. In this case you can call its get method.

thanks so much, I did end up using the $http service instead...albeit a slightly different way... code $http.get('/json').success( function(response){ $scope.reports = response; getData(); code what is interesting to me, is the promise object...I really want to learn more about that. I love the idea of it. The other problem I have been having is basically running a loop on the ajax request so i can constantly "automagically" refresh the page. $timeout has not been working for me.
–
MJR_IIIOct 25 '12 at 10:13

1

I believe it should be $scope.todos = res; instead of res.data.
–
AnoyzNov 14 '13 at 21:22

The response object has four properties: config, data, headers and status. The values in the data property are what you want.
–
jaimeNov 14 '13 at 22:25

1

worth having a $scope.todos = []; before the http request, so you at least have a default empty structure so as not to throw errors in your template.
–
SamApr 15 '14 at 17:16

This example works fine in Firefox, but not in Chrome.
–
SubhoAug 29 '14 at 8:03

Does this actually work? Your JSON is invalid (the keys are not in quotation marks). Don't you get errors?
–
ImrayNov 13 '14 at 22:01

Sorry, you're right. I took the screenshot above from Google Chrome with the excellent JSONView addin installed (so you can view the JSON in a nicely formatted way). But yes, the JSON from my web service is valid. If you click on the link in my article, you can view a live version of this code.
–
Mike GledhillNov 14 '14 at 8:22