angularjs - Angular.js reading External JSON Address -
O people, I am trying to use an EPA API which provides daily UV index information in the USN.
http://iaspub.epa.gov/ Enviro / efservice / getEnvirofactsUVHOURLY / ZIP / 33126 / JSON? Callback = callBackFn
If you open that link it shows valid JSON, but when I do it in my Angular.js code I do not read it, and my variable remains in the form of an unknown. My code is:
var tanApp = angular.module ('tanApp'). Controller ('MainCtrl', ['$ scope', '$ http', function ($ radius, $ http)) {$ Scope.awesomeThings = ['HTML5 boilerplate', 'angels', 'karma']; $ Scopedata = 'unknown'; $ Http.get ('http://iaspub.epa.gov/enviro/efservice Success (work (data) {$ scope.data = data;}); tanApp.config ([' $ httpProvider ', function ($ httpProvider ) {$ HttpProvider} / $ / HTTP / .defaults.useXDomain = true; $ httpProvider.defaults.headers.common ['x-requested-with'];}]);
My HTML code is {{data}}.
When I remove the "JSON" portion, it comes in the form of XML, because it is the default, and it is actually showing, but I need it JSON.
> Can anyone possibly get to work or provide some helpful? I can provide bitcoin as a gift.
Thank you!
The problem is that the URI is you using JSON instead of JSON instead of JSONP. You can either set up a server-side prox or check to see if you have a way to get a valid JSONP response, with your API provider.
If you can get a legitimate JSONP, you will also have to setup the callback to handle the feedback.
In that case, the accepted answer for reference.
Comments
Post a Comment