<img src="assets/img/spinner.png">
,
duration: 5000
}); - Nirajimport { LoadingController } from 'ionic-angular';
然后创建一个属性,并将其注入到类构造函数中
export class LoginPage {
loading: any;
constructor(public loadingController:LoadingController){...}
}
login() {
this.loading = this.loadingController.create({ content: "Logging in ,please wait..." });
this.loading.present();
this.errors = "";
//api service call
this.authService.postData(this.userData, 'api/account/login').then((result) => {
this.responseData = result;
if (result != null) {
this.loading.dismissAll();
//console.log(result);
this.common.setLocalData(DataKey.User.toString(), result);
this.navCtrl.push(TabsPage);
}
else {
this.loading.dismissAll();
this.errors = "Nope, Try Again";
}
}, (err) => {
this.loading.dismissAll();
this.errors = "Nope, Try Again";
// Error log
});
}
当您成功登录后,方法dismissAll()会隐藏加载指示器,以便您可以继续正常地与应用程序进行交互。
代码
吗? - Sampath