AngularJs $resource return my Java Enum as an array from a REST service -
i'm pretty new angularjs, , have trouble retreiving correctly java enum rest service. code put @ end of question, here result got : {"0":"c","1":"u","2":"s","3":"t","4":"o","5":"m","6":"e","7":"r"} it's array, excpecting simple string. maybe miss how transform string ? can't find correct way ...
here controller :
angular.module('myapp') .controller('labcontroller', function ($scope, labservice) { $scope.clientouabonneresultat = ''; $scope.clientouabonne = function () { labservice.get({noclient: 10002782, nocontrat: 1003}, function(result) { $scope.clientouabonneresultat = result; }); }; });
my service :
angular.module('myapp') .factory('labservice', function ($resource) { return $resource('api/lab/clientouabonne', {}, { }); });
my backend implementation :
@restcontroller @requestmapping("/api/lab") public class labresource { private final logger log = loggerfactory.getlogger(labresource.class); @inject private labservice labservice; @requestmapping(value = "/clientouabonne", method = requestmethod.get, produces = mediatype.application_json_value) @timed public customertypeenum getperiodefacturation(@requestparam(value = "noclient") long noclient, @requestparam(value = "nocontrat") long nocontrat) throws urisyntaxexception { return labservice.isclientouabonne(noclient, nocontrat); } }
and finally, enum :
public enum customertypeenum { customer, subscriber, none; }
Comments
Post a Comment