Use custom javascript / third party javascript inside a provider


im having a problem to use custom javascript / a third party javascript library inside a provider! how do i realize that?

the javascript file is not listed in the npm repository, so this seems not to work:

this solutions seems to work inside page but not inside a provider:

best regards

was the 3rd party an NPM package?

What’s the error you are getting?

as mentioned above: the 3rd party is not in the npm repository, so no it is no npm package

when loading the library in my index.html (as suggest) and i try to use it in my provider, im getting the message that the object i want to use is not defined when i try to access it… in a page component it works without problems…

i guess the problem is that the provider is initialized before the application is bootstrapped completly… im injecting the service in my app.components.ts (main class) in the constructor, i think the issue might be that this way the provider is initialized before the index.html is created, which loads the library

If that’s the issue, you can probably just call the provider after the platform is ready.
platform.ready() => this.providerName.methodName();

Edit: Also, don’t put anything in the provider’s constructor or ngOnInit. If you need to initialize the provider, put that code in an initializeProvider() method, and call that method after the platform is ready.