Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 229726

Using an API globally across an app

$
0
0

I'm only about 3 months in to Ionic, so I'm no pro, and won't go into detail. But, I was terribly confused by this concept at first too. To literally create a provider, run ionic generate provider myProvider Replace myProvider with whatever you want. Now you have a provider. It's not something that you install, not a plugin or anything. To import that provider into your seperate pages, add import { myProvider } from '../providers/my-provider'; Or whatever path gets you to your provider folder. Do the same in your app.module.ts file, then add myProvider (or your name for yourProvider) to the section called providers: [ ] also in app.module.ts.
It'll look like this:
providers: [
StatusBar,
SplashScreen,
myProvider
]

After those steps are done, you can link to API's, databases, etc... and pass data around with that provider. Someone else will have to take over at this point. But that's a pretty clear cut start.


Viewing all articles
Browse latest Browse all 229726

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>