Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No provider for Storage! #55

Closed
garyforsterio opened this issue Dec 21, 2016 · 3 comments
Closed

No provider for Storage! #55

garyforsterio opened this issue Dec 21, 2016 · 3 comments

Comments

@garyforsterio
Copy link

Hey,

Great work with Ionic 2 guys. I've imported and injected the ionic-storage export ({ Storage } from '@ionic/storage') as a provider in NgModule. I've then imported it and DI it into a service. The problem is, as well as injecting this service into any component which uses it, we are also having to import Storage as well.

Does anyone know why this would be the case?

Thanks

@shawnlauzon
Copy link

That sounds right.

In my file LocalStorageProvider which accesses storage, I have:

import { Storage } from '@ionic/storage';

And then in app.module.ts:

import { Storage } from '@ionic/storage';
import { LocalStorageProvider } from '../providers/local-storage';

@NgModule({
  providers: [
    Storage,
    LocalStorageProvider,
    ...

@maitham
Copy link

maitham commented Dec 21, 2016

In our app.module.ts we have the following.

` import {ProfileService} from '../providers/profile.service';
import {Storage} from '@ionic/storage';
@NgModule({
  providers: [
    Storage,
    ProfileService,
    ...

However for any page that utilises the profileService, where we run the following

import {Storage} from '@ionic/Storage'
constructor(private af: AngularFire, public storage:Storage) {
   af.auth.subscribe(state => {
     if (!state) {
       return;
     }
     this.storage.set('userUID', state.uid);...

We are getting an error main.js:51716 ORIGINAL EXCEPTION: No provider for Storage!

Struggling to understand why ?

@garyforsterio
Copy link
Author

The issue was on our end. We were declaring the services in each page and not module wide. Fixed now, thanks @shawnlauzon. Closing issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants