LocalStorage and click counts


#1

Hello everyone, I’m a young italian student and I’m moving my first steps into the world of Ionic. I’m delevoping a simple application, and I need to use LocalStorage to count the number of clicks on a specific button, and use this value in another page of the application. How can I do that?

Thanks for your support!
Alessandro


#2

Have a look at using https://ionicframework.com/docs/storage/

For the local storage.

And you can use a provider to gain access to your data in multiple places of your application.


#3

page html :

        <button ng-click="count();">clic</button>

page js :

function count() {
localStorage.setItem("nbclic",localStorage.getItem("nbclic")+1) ;
}

Something like that on ionic v1.