In my AngularJS application, I have implemented an update form that allows users to post updates. After submitting the form, the JSON file is immediately updated as expected. To return to the main page upon pressing the save-update button, I utilize $window.location.href
.
However, upon returning to the main page, the data displayed is not automatically refreshed. Although refreshing the page manually (by pressing F5) works, I am seeking a way to have the data updated automatically upon returning to the main page.
Based on the information I have researched regarding $window.location.href
reloading the page, I had anticipated that this would also refresh the data when changing the location in my application. Unfortunately, this does not seem to be the case currently.
Is there a method to have the data on the main page updated without requiring manual page refresh?
Form Controller:
myDash.controller("dbNewUpdateCtrl", function($scope, $window, dbDataService){
//Save + Cancel
$scope.updateSave = function (item) {
dbDataService.saveUpdate(item);
$window.location.href = "#/dashboard";
}
$scope.updateCancel = function () {
$window.location.href = "#/dashboard";
}
});
Main Page Controller
myDash.controller("dbOverviewCtrl", function($scope, $routeParams, dbDataService){
$scope.items = dbDataService.getData();
});