Toggle save value using localstorage


#1

I’m trying to save the state of a toggle (whether it’s toggled or not) using localstorage, but it’s not saving or showing the saved value;

My code is:

<li class="item item-toggle">
                    Loonheffing
                    <label class="toggle toggle-positive">
                        <input ng-model="loonheffing" 
                               ng-change="setLoonheffing(loonheffing)" 
                               type="checkbox">

                        <div class="track">
                            <div class="handle"></div>
                        </div>
                    </label>
                </li>

Javascript

$scope.setLoonheffing = function (value) {
        window.localStorage['loonheffing'] = value;
    }
$scope.loonheffing = window.localStorage['loonheffing'] || true;

#2

You might have found the same problem I did. There was an update to the chrome web view that borked local storage. See link: https://code.google.com/p/chromium/issues/detail?id=481380


#3

You’re right, it’s the browser. I tested it on my phone and it worked perfectly fine.