Thanks for response. I understand that if I inject service in Component1, it will be available only in it’s subcomponents.
But how create Component1 ?
Ionic2 navigation implemented by using navController.push(SomeComponent). And SomeComponent is not a lover level component for component from which I make a navController.push
With Ionic/Angular 2 I keep my “services” seperated.
For instance I need a service that will provide some utilities, such as converting a number to a string …
I will create a file called Utils.ts, and put the following content in it:
I would also like to add that the functions inside that class do not have to be static. They can be regular functions too but that will require you to instantiate an instance of the class by calling new Utils().
If your class will have non-static functions then I recommend looking into creating an Angular 2 Injectable although it’s unnecessary and will only save you few lines of code each time you use the service.