I have a service defined like this ->
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 the controller this is how I have called the 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 the product code to the server and the server returns with an array in the response. I have used isArray: true, however it still keeps giving me an error. I don't a 'value' variable/object in my code.
Please suggest how can I fix this.
This is the complete error that I get ->
Error: value.push is not a 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 is the response from the 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"}]