Make function in a component available in other sides

I’ve just began to work with ionic. I was successfull to use function from a provider in other pages. But now, I have some functions declared in a components. Is it possible to access these functions in others pages too?


While technically this is possible this should be considered hacks that go against the architecture of angular

If u like to avoid common pitfals and learn how to think angular (currently the underlying framework for ionic 2/3), go to and follow the tutorial

If u dont like angular, then u should wait until ionic 4 is out and choose your favorite framework, react, vue, jquery, none at all

Josh morony has great tutorials. Check google.



1 Like

Thank you! But can you also explain me, how to use the function of the component in a other page? Is it the same way, which Josh Morony discribe in his tutorial about providers?
Or is it a good solution, to store all functions, which have to be accessable in all pages, in one provider?

Providers are indeed the place for common functions, related to common data (in a singleton provider)

I see btw also sometime code with generic helpers placed in files imported as module (date calculations, hashing etc). Basically you are making ypur own js library then

So if the functions u refer to are unrelated to common data then such could be a way to go

Thank you very much for your kindly explanations!