Hi, I cannot get my head wrapped around the ng-model and how it works in this particular case:
CodePen example here
It saves already the true/false state into the localStorage, so when the page is refreshed, I reads out the previously set state for each item. But the checkboxes don’t display the state (e.g. showing the checkmark or not).
How can one access the true/false state so, that it can be passes it to the checkbox itself?
Wow, lovely! Thank you so much, brandyshea you made my day with this!
You’re welcome. Have you looked into ngStorage? You might have reasons you can’t use it, but I wanted to throw it out there. I’m using it in a project and it made life easier for me.
I wasn’t aware of
ngStorage till now, will check it out tomorrow. As far as I can see you did not use it in this Pen? Or did you, and that’s what you mean with throw out? However, you made me curious for this.
I didn’t use it in the pen, I kept it the way you were doing it. Here is a blog on using ngStorage with Ionic: https://blog.nraboy.com/2014/12/use-ngstorage-angularjs-local-storage-needs/
If you need me to put a codepen together, I can.
This post looks good. Many thanks. I don’t want to bother you too much! But if you really want to pen a bit, I’d love to see it. Also it might be a super fly reference for others No rush.
It’s not a bother at all. I threw together an example using the code above: http://codepen.io/brandyshea/pen/qdEwWQ?editors=101
Hey Brandy, I checked all your links and your CodePen now (sorry for the delay). This is some promising stuff right here, especially for me who is new to angularJS. Thanks so much for the tip and the effort to write the Pen. I really appreciate your output! I’ll probably try to go for ngStorage in my project now.
I got it working, even in the ionic view app. It seems to not work in Xcode, though. Hence one thing I wonder: will this ngStorage.js be included properly in the final App later? I got it in the index.html next to the other scripts like this:
I am not aware of these kinds of dependencies and how ionic handles them when the distribution is going to be done. Maybe one better downloads it and puts it into the js folder?