post - AngularJS - Error: value.push is not a function -


i have service defined ->

storegrservices.factory('productlist', ['$resource', function($resource) {     return $resource('', {},{         query: {url:'/apis/productshome.php', method:'get', isarray:false},         getproductdetail: {url:'/apis/getproductdetail.php', method:'post', isarray:true}     }); }]); 

and in controller how have called post ->

storegrcontrollers.controller('productpagectrl', ['$scope','productlist','$routeparams', function($scope, productlist, $routeparams) {     $scope.postvariable = new productlist();     $scope.postvariable.productcode =  $routeparams.code;     $scope.postvariable.$getproductdetail(); }]); 

this sends product code server , server returns array in response. have used isarray: true, still keeps giving me error. don't 'value' variable/object in code.

please suggest how can fix this.

this complete error ->

error: value.push not function resourcefactory/</resource[name]/promise</<@http://storegr.com/js-lib/angular-resource.js:530 q@http://storegr.com/js-lib/angular.min.js:7 resourcefactory/</resource[name]/promise<@http://storegr.com/js-lib/angular-resource.js:529 yd/e/k.promise.then/w@http://storegr.com/js-lib/angular.min.js:92 yd/e/k.promise.then/w@http://storegr.com/js-lib/angular.min.js:92 yd/g/<.then/<@http://storegr.com/js-lib/angular.min.js:93 zd/this.$get</h.prototype.$eval@http://storegr.com/js-lib/angular.min.js:101 zd/this.$get</h.prototype.$digest@http://storegr.com/js-lib/angular.min.js:98 zd/this.$get</h.prototype.$apply@http://storegr.com/js-lib/angular.min.js:101 f@http://storegr.com/js-lib/angular.min.js:66 f@http://storegr.com/js-lib/angular.min.js:70 md/</b.onreadystatechange@http://storegr.com/js-lib/angular.min.js:71 http://storegr.com/js-lib/angular.min.js line 84 

this response server ->

[{"sno":21,"cat1":"beverages","cat1code":"b","cat2":"carbonated drinks&fruit drinks","cat2code":"cdd","cat3":"fruit juices","cat3code":"fj","cumulative":20,"brand":"real juice","product":"apple","productcode":"b-cdd-fj-1","imagename":"b-cdd-fj-1","weight":200,"unit":0,"mrp":20,"margin":0,"wsp":0,"vat":0,"hbprice":0,"discount":0,"availableqty":0,"availableprice":0,"existingqty":0,"existingprice":0,"addedqty":0,"addedprice":0,"soldqty":0,"soldprice":0,"tags":"home"}] 

i able work around, answering here benefit 1 else too.

i modified array response json object , worked.

{ "product": [{"sno":21,"cat1":"beverages","cat1code":"b","cat2":"carbonated drinks&fruit drinks","cat2code":"cdd","cat3":"fruit juices","cat3code":"fj","cumulative":20,"brand":"real juice","product":"apple","productcode":"b-cdd-fj-1","imagename":"b-cdd-fj-1","weight":200,"unit":0,"mrp":20,"margin":0,"wsp":0,"vat":0,"hbprice":0,"discount":0,"availableqty":0,"availableprice":0,"existingqty":0,"existingprice":0,"addedqty":0,"addedprice":0,"soldqty":0,"soldprice":0,"tags":"home"}] } 

thank you.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -