I’m very new to Ionic and Angular, so I’m having some difficult getting started on very simple concepts. I’m trying to get the value/state of form elements and am having trouble with the checkbox toggles.
Basically, I need to track when a user changes the state, save it to localStorage, and then load use it to load again later - so it remembers their settings.
My toggle code looks like this:
<li class="item item-toggle"> National Insurance <label class="toggle toggle-positive" id="has_ni_toggle" name="has_ni_toggle"> <input type="checkbox" id="has_national_insurance" name="has_national_insurance" checked="checked"> <div class="track"> <div class="handle"></div> </div> </label> </li>
Note: I’m using the HTML and not
<ion-toggle> because I’m still learning AngularJS and don’t fully understand the concepts right now.
I really just want the simplest way to grab the current value of the toggle and store it in a variable that I can then use to save to localStorage. Do I need a listener for when the state changes, or what is the best way to go about this?