which is obviously just a partial, where and how do I declare variables that I can access in any of my class functions. I tried putting them in the constructor but those get cleaned each time the service is called.
Getting familiar with Typescript is easy as read a couple of articles of differences or features, and get some practice. I’m super happy now using it, and ionic CLI makes it all easy anyways. BTW, JS is not supported anymore from Ionic 2 beta9 onwards.
Totally agree with what you’re saying and I realise I need to do this.
However, is there any chance you could answer the question? I need to get this done and converting all the JS code I’ve already done to produce a working demo is not efficient at this point in time.
Yes I’ve tried that. The problem is that I’m using a service to maintain some global states and doing it this way resets the variable to the initial value each time the service is called. I need to set a class level variable outside the constructor.
It sound to me like you’re not using a single instance of the Service for your app.
Angular 2 providers work as a singleton if you declare them once, but if you require them in multiple pages, each page will have a different instance. In your App providers, require your TaskService, then you can use Dependency Injection in any of your pages, and will be a single one for your app