Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48983

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

4 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 48983

Trending Articles



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