Reputation: 24602
Some of my user screens have select
tags looking like this:
<select
data-ng-disabled="option.subjects.length == 0"
data-ng-model="option.selectedSubject"
data-ng-options="item.id as item.name for item in option.subjects">
<option style="display: none" value="">Select Subject</option>
</select>
Rather than show the "Select Subject" default, is there a good way that I could check local storage and retrieve a value for my select
that was stored the last time I made a choice?
Upvotes: 0
Views: 522
Reputation: 2781
Yes, check this one out. This is the best one I've found yet.
---> angular-local-storage
Here's a DEMO
var YourCtrl = function($scope, localStorageService, ...) {
// To add to local storage
localStorageService.add('localStorageKey','Add this!');
// Read that value back
var value = localStorageService.get('localStorageKey');
// You can also play with cookies the same way
localStorageService.cookie.add('localStorageKey','I am a cookie value now');
}
Upvotes: 3