I'm an beginner in angularjs and don't have any idea about web services either. My requirement is something like this:
I have to get a JSON object from my url http://mylocalhostname.dev/users/list?city_id=12
I'm absolutely clueless...Please help me out by modifying my code.
Thanks in advance. Here's my JS code:
'use strict';
var services = angular.module('services', ['ngResource']);
services.factory('dataFactory', ['$resource','$http', '$log',
function ($resource, $http, $log) {
return {
getAllUsers: function(){
return $resource('http://mylocalhostname.dev/users/list',{city_id:12}
,{
locate: {method: 'GET', isArray: true, transformResponse: $http.defaults.transformResponse.concat(function(data, headersGetter)
$log.info(data.UsersList[0]);
return data.UsersList[0].userName;
})}
}
);
}
}
}]);
when i test i get this message in my console :
GET http://mylocalhostname.dev/users/list?city_id=12 200 OK 164ms angular.js (ligne 7772) (in color red) (an empty string)