This questions has been answered on a different post. See here: Displaying json data in an Angular App
1 Answer
Here is the demo http://dojo.telerik.com/UkUbE
var app =angular.module('PhoneCat',[]);
app.factory('info', ['$http', function($http){
var data = {};
data.getInfo = $http.get('http://cdn.rawgit.com/angular/angular-phonecat/master/app/phones/phones.json')
.success(function(data){
return data;
})
.error(function(err){
return err;
});
return data;
}]);
app.controller('HomeController', ['$scope','info',
function($scope, info) {
info.getInfo.then(function(res){
$scope.datar = res.data;
});
}]);
Hope this may help you
2 Comments
Thibaud Sowa
For me the
success and error methods in info service are uselessCodeArt
The code above seem to work, I believe the error has to do with the specific json feed I'm trying to work with (which doesn't seem to work), this: api.flickr.com/services/feeds/…