I'm having trouble to load some data from a web service. I created this factory:
.factory('urlService', function($http) {
var service = {
getURLStatus: function(urlElgg){
var urlElgg = 'http://'+urlElgg+'/services/api/rest/xml/?method=system.api.list';
$http({method: 'GET', url: urlElgg}).
success(function(data) {
console.log("success");
}).
error(function(data) {
console.log("error");
});
}
};
return service;
})
And I have this in the controller:
$scope.doAddCommunity = function() {
console.log('Doing Add Community', $scope.communityData.url);
urlService.getURLStatus($scope.communityData.url);
};
Everything looks OK, but when I send an url always get "error" instead of "success". What I am doing wrong?
angular.toJson(data)in theconsole.log()on the Error callback and post the error message here.console.log("error")withconsole.log(data)and tell us what you get in the console.dataobject, which you can log by doingconsole.log(angular.toJson(data))in that part and checking its value in the browser console.