asp.net - calling one of multiple services in angularJS $resource -
is there wrong code trying have 1 service method point different restful services?
var phonecatservices = angular.module('phonecatservices', ['ngresource']); phonecatservices.factory('phone', ['$resource', function ($resource) { return { plist: $resource('/:url/:phoneid.json.htm', {}, { query: { method: 'get', params: { url: 'myangularscripts', phoneid: 'jsonphonedata' }, isarray: true } }), pdetail: $resource('/content/phonesdata/:phoneid.json.htm', {}, { query: { method: 'get', params: { phoneid: $routeparams.phoneid }, isarray: false } }) }; }]); then in controller call plist this:
$scope.phones = phone.plist.query(); the service method doesnt called of code above. if change service this:
var phonecatservices = angular.module('phonecatservices', ['ngresource']); phonecatservices.factory('phone', ['$resource', function ($resource) { return $resource('/:url/:phoneid.json.htm', {}, { query: { method: 'get', params: { url: 'myangularscripts', phoneid: 'jsonphonedata' }, isarray: true } }); }]); and call controller this:
$scope.phones = phone.query(); it works. wrong service have multiple restful calls declared? wrong way configured or way calling it?
the 1st approach should working fine well.
the oroblem trying access property of $routeparams, without first injecting via di, resulting in error being thrown.
if correct this, should work expected.
Comments
Post a Comment