Nazehs
Nazehs

Reputation: 558

Constructor throwing an exception in ionic 4

I have a page in ionic 4 that if I import more than 1 services it will throw an exception and the page is not loading(if i use a single service it would load the page). This same code was working before now without issues and I think its because of the recent update of angular and ionic

Below is the code I have


import { MenuController, IonSlides } from '@ionic/angular';

import { Storage } from '@ionic/storage';
import { ViewChild, OnInit, Component } from '@angular/core';

@Component({
selector: 'app-onboarding',
templateUrl: './onboarding.page.html',
styleUrls: ['./onboarding.page.scss'],
})
export class OnboardingPage implements OnInit {

showSkip = true;

@ViewChild('slides', {static:false}) slides: IonSlides;

constructor(
 public menu: MenuController,
 public router: Router,
 public storage: Storage
) {}

ngOnInit() {
}

}

Below is the screen dump of the error i keep getting

enter image description here

Upvotes: 1

Views: 151

Answers (1)

dev-dan
dev-dan

Reputation: 6283

This is basically telling you it cant resolve

public storage: Storage

Try checking where you are importing this from. If its from a barrel try importing it directly from where it is defined.

A good IDE should be able to nail these imports for you, and highlight when you are not importing.

Ensure '@ionic/storage' is installed through npm and the relevant version is being used for your project.

Upvotes: 1

Related Questions