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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -