I am trying to execute a fuction when a change occurs in one tab, the change should reflect in other tab too.
i write this and it is working fine in the same tab i change even i check manually browser localstorage and see it works nice.
but the problem, the change not reflect in other tab too.
I mean, i opened two tab and when i change something in one tab, in other tab it should reflect.
Whenever any change occurs in one tab, 2nd tab should execute this $scope.getAllContact();
and wait for another change, if another change occurs, $scope.getAllContact();
should be executed.
$localStorage.editedData = response.data;
$scope.editedID = $localStorage.editedData.id;
if (response.data.id == $localStorage.editedData.id) {
$localStorage.isChanged = true;
}
while ($localStorage.isChanged == true) {
$scope.getAllContact();
break
}
I write above code;
Ignore below this code if you undertand above few line, below code is fuction, when change occurs, the fuction should be executed:
$scope.getAllContact = function() {
var data = $http.get("http://127.0.0.1:8000/api/v1/contact")
.then(function(response) {
$scope.contacts = response.data;
// below two line of codes will reload in every 10 millisecond if a request succcess
// in result, you will see refleation in other browser if any change occurs in another browser
// do nothing for now
}, function(response) {
//$scope.connectionError = "Opps ! Having Trouble in loading this page ! \n It's Connection Error !!!";
// below two line as as above two commented line
// do nothing for nw
});
};
$scope.getAllContact();