Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70804

LoadingController not injected in the component and remains undefined

$
0
0

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

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 70804

Trending Articles