json - Invalid result from ngResource request with string array -
i've following ngresource defined:
angular.module('licenseservices', ['ngresource']). factory('license', function ($resource) { return $resource('api/licenses/:id', { id: '@id' }, { //... 'getlicensetypes': { method: 'get', url: 'api/licenses/types', isarray: true } }); });
the result of request is:
["trial","standard"]
but using resource in controller:
$scope.licensetypes = license.getlicensetypes()
i following result:
licensetypes: [ undefined, { 0: s 1: t 2: 3: n 4: d 5: 6: r 7: d } ]
i'm using angularjs 1.1.4 chrome.
whats wrong resource definition?
there not point in using $resource
data structures those. thing $resource
works great restful endpoint http verbs used. make easy angualarjs extends incoming objects convenience methods ($save, $delete etc.). if return primitives there no room extension , 1 of major benefits of $resource
gone.
in short: if after fetching data $resource overkill imo, stick $http
instead.
Comments
Post a Comment