Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can localstorage value persist across opened tabs/windows ? #269

Open
Vikram0811 opened this issue Aug 19, 2017 · 1 comment
Open

Can localstorage value persist across opened tabs/windows ? #269

Vikram0811 opened this issue Aug 19, 2017 · 1 comment

Comments

@Vikram0811
Copy link

Vikram0811 commented Aug 19, 2017

Hi,

We ran into an issue when language is changed from one tab, it is not being reflected in another already opened tab. We are using below code to set language in cookie.

if (angular.equals(addcookie, "Yes")) {
$cookieStore.put('lang', langKey);
}

We tried below code to set language in localstorage

$localStorage.language = langKey; //EN/FR

The language is set, but if user changes language from one tab, it is not reflecting it already opened tab.

Further we tried like below

$scope.$storage = $localStorage.$default({
           language : langKey
       });

$scope.$watch(function() {
     return angular.toJson($scope.$storage);
       }, function() {
          console.log('The language is *** '+$scope.$storage.language);
   });

But the above also does not seem to be working.

Could you please explain how do we use your extension in order to reflect the language change across all the opened tabs/windows ? Also does it work with open windows too apart from open tabs ?
We want a user to have multiple browser tabs/windows open of the same website and dynamically change the content on both tabs (Which are the same view) based on the localstorage.

@sblaauw
Copy link

sblaauw commented Aug 23, 2017

@Vikram0811
This work between two tabs/windows. I created a quick test using a checkbox.

Controller:

$scope.$storage = $localStorage;

View:

<input type="checkbox" ng-model="$storage.test">
<pre>
    test: {{$storage.test}}
<pre>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants