last day (15 days later) » 

8:04 PM
1
A: How to return a function into a scoped variable?

Justin PowellIf you're trying to print out the reference to the function itself, then what you have is correct (other than the syntax error mentioned by DenimChicken): annApp.factory('rssFeed', function(){ return function(){ var events = []; $.get('xmlfile', function(xml){ var...

 
I was able to get the callback function to work properly using another stackoverflow question found here stackoverflow.com/questions/20369377/….
After being able to create the callback I am not able to display the object data on the page however, I am able to return the object to the console window. Ideas?
 
Can't say without seeing your code. If you put it in a jsfiddle, post the link and I'll take a look.
 
You were using the jQuery $.get ajax method, which does not notify Angular that it needs to update its bindings. If you change it to use Angular's $http provider, it will work. (jsfiddle.net/9rv9ahcp/2)
Also, it looks like the URL you're using is in error.
 
Sorry about this. I have this URL sitting behind a firewall.
How would I be able to use $http when the data I am getting is an RSS feed?
 
8:04 PM
$http.get is essentially the same as jQuery's $.get, only it plays nicely with Angular.
 
This returns as an object and not as a XML feed. $.get returns correctly $http.get does not.
 
Are you looking at the jsfiddle I posted 2 comments ago?
 
8:15 PM
I looked at it am trying to figure out how to get promises to work. I am having a hard time understanding how to get this to work.
I went ahead and updated what I have. I was having a difficult time with the callback function so I went ahead and used the default angular $http service.
It seems that I have to pass in $http into my service in order for it to function properly. So is there a way I can return the value using a promise?
 
8:31 PM
You can use the callback function approach with angular's $http provider
That's what I was doing in my example at jsfiddle.net/9rv9ahcp/2
 

  last day (15 days later) »