After saving an object, I am looking to update an array by replacing the conventional push
method with a custom function. However, my attempts have not been successful so far. Are there any suggestions on how to rectify this issue?
app.controller("productController", function($scope, $http, createProductService, listProductsService){
$scope.addProduct = function(){
var newProduct = createProductService.createProduct($scope.product);
//$scope.products.push(newProduct);
updateArray();
};
$scope.products = listProductsService.query();
var updateArray = function(){
$scope.products = listProductsService.query();
}
}
app.factory("listProductsService", function($resource){
return $resource("getAllProducts", {}, {
listProducts: {
method: "GET",
isArray: true
}
})
})