I have this HTML
<button class="btn btn-info" ng-click="setLanguage('en')">English</button>
<button class="btn btn-info" ng-click="setLanguage('de')">Danish</button>
<p>{{name[language]}}</p>
and javascript
$scope.language='en'; //initial default value
$scope.setLanguage = function(language) {
$scope.language = language;
}
i am binding language to button for 2 languages.based on the language selected, the content will be shown. how to store en
or de
to localstorage. if i refresh or change the page also, the set language should be same. how to do it. can anyone help me
Here is the plunker http://plnkr.co/edit/zHMvBWCKevKgGeBerhhE?p=preview
localStorage.setItem(key, value)
andlocalStorage.getItem(key)
? I don't know why you need ngStorage if you just want to use localStorage. – AntiHeadshot