I have this strange situation where I don’t understand why the LoadingController is not injected.
this is my code:
@Component({
selector: 'app-login',
templateUrl: './login.page.html',
styleUrls: ['./login.page.scss'],
})
export class LoginPage implements OnInit {
constructor( private loadingController: LoadingController) {
}
ngOnInit() {
this.showLoading(true);
}
showLoading(show: boolean) {
this.loadingController.create({
message: "Login...",
animated: true,
spinner: "circles",
duration: 5000
}).then(loadEl => {
if (show) {
loadEl.present().then();
} else {
loadEl.dismiss().then()
}
});
}
}
When I run my app I have this error:
ERROR TypeError: Cannot read properties of undefined (reading 'create')
at SafeSubscriber.showLoading [as _next] (login.page.ts:61)
LoadingController
is undefined, what am I doing wrong?
Thanks
4 posts - 2 participants