如何在离子3中导入loadingController?

时间:2017-09-07 23:23:44

标签: ionic-framework

我有一个在离子2上运行的应用程序,但是我将它升级到离子3并且在升级后,一些离子插件不起作用,就像LoadingController甚至平台一样。

生成错误"找不到名称' LoadingController'"。

我查看了离子文档并且现在没有弄清楚如何导入它们

按照我的代码:

import { LoadingController, Platform } from 'ionic-angular'

@Component({
 selector: 'app-root',
 templateUrl: './app.component.html',
 providers: [ ProfileService, AlertService ]
})

export class AppComponent {
  constructor(private router: Router, 
   public loadingCtrl: LoadingController,
   private activatedRoute: ActivatedRoute, 
   private loginService: LoginService, 
   private profileService: ProfileService,
   private _alertService: AlertService,
   private platform: Platform ) {
    router.events.subscribe((data) => {
      this.path = data.url.substr(1);
    })

    this.getUserName();
    this.platform.ready().then(() => {
      this.platform.registerBackButtonAction(() => {
        history.go(-1)
      });
   });  
 }}

1 个答案:

答案 0 :(得分:2)

<强> LoadingController ionic 3 loadingController链接

<强> home.html的

    <ion-header>

  <ion-navbar>
    <ion-title>Loading</ion-title>
  </ion-navbar>

</ion-header>


<ion-content padding>

  <button ion-button (click)="loading()">Show Loading</button>

</ion-content>

<强> home.ts

import { LoadingController } from 'ionic-angular';
export class LoadingPage {

  constructor(public navCtrl: NavController,public loadingCtrl: LoadingController) {
  }
  loading(){
    let load = this.loadingCtrl.create({
      content:'Please Wait....',
      duration: 3000
    });
    load.present();
  }
}