I have set up a static json file to act as my server and fetch an array of orders from it. These orders are displayed in a table on my HTML page, with the ability to delete them individually. However, every time I refresh the HTML page, the full list is reloaded, including the orders that were deleted using the controller function.
Is there a way to load the data from the factory just once?
Below is the code snippet for my controller:
app.controller("MainPageCtrl", function($scope, getOrdersFactory)
{
$scope.orders = [];
// Fetching the data from the factory
var dataPromise = getOrdersFactory.getDataFunc();
dataPromise.then(function(data){
$scope.orders = data.orders;
});
// Function to delete an order
$scope.deleteOrder = function(order){
// Find the index of the order
var orderIndex = $scope.orders.indexOf(order);
// Remove the order
$scope.orders.splice(orderIndex, 1);
};
});