I was able to get it working for a checkbox (radio button won’t be long to solve), however, now it persists for all lessons because I’m using ng-repeat! Any help on how I can persist it for the selected lesson only? Thanks
Be honest the local storage is not the best place to store your data. It is more notepad than a database. You cant really simulate a full CRUD via window.localStorage.xxxItem(). At least you need some good tooling/API . If you insist on localstorage you can use https://github.com/auth0/angular-storage .
But I would recommend you something more stable, I believe both Android and iOS could eventually release the ‘memory’ during the weekly cleaning. You can go with Localforage ( https://github.com/ocombe/angular-localForage) or brand new Lovefield (https://github.com/ben--wood/LoveField-Starter).
I would personally recommend you the http://www.js-data.io/ . It has a huge overhead at the beginning but thereafter you have an data driven app that uses single interface for all databases. In Ionic apps you can use the localforage adapter just for persistency, and once you need a real server-side database, you just change the adapter [abt 5 LOC in .config()] and everything should work.
Thanks! I agree with you … I thought localstorage is more ‘permanent’ solution so I don’t need to involve server side for such a simple action … I don’t even want to ask user to signup/login to do this …
It depends on how complex is your “database”. Once all your data belonging into one big pile/array of objects, you have to alter the detail object and then make sure the whole array will be saved into a storage. It could happened in many places in many views of your apps and it would be really tedious. Mentioned modules/APIs would provide you with a comfort of “advanced” databases even if you are still using a in-browser storages.
If TLDR: using one of the mentioned modules/APIs would make your live much easier