ionViewDidEnter() { let loading = this.loading.create({ content: 'Loading items...' }); loading.present(); setTimeout(() => { for (let i = 0; i < 30; i++) { this.items.push({ name: 'ionic' }); } loading.dismiss(); }, 3000); }
loadUsers() { let loading = this.loading.create({}); loading.present().then(() => { this.userService.getAll() .then(users => { this.users = users; loading.dismiss(); }, (error) => { this.users = []; loading.dismiss(); }); }); }
loadPhotos() { let loading = this.loading.create({}); loading.present().then(() => { this.photoService.getAll(this.album.id) .then(photos => { loading.dismiss(); this.photos = photos; }, (error) => { loading.dismiss(); this.photos = []; }); }); }
/** If already registered then login using the following function. Check firebase and login */ login() { /** Show Loading till they login */ let loading = this.loading.create({ content: 'Please Wait..' }); loading.present(); /** check authentication from provider */ this.auth.loginWithEmail(this.form).subscribe(response => { console.log(response); loading.dismiss(); }) }
handler: data => { console.log('Saved clicked'); let loading = this.loadCtrl.create({ content: "Getting songs..." }); loading.present().then(() => { this.musicService.getFirstTracks(data.term).then((tracks) => { this.songs = tracks; loading.dismiss(); }); }); }
login() { const loader = this.loadingCtrl.create({ content: "Please wait..." }); loader.present(); this.isFailed = false; this.isSuccess = false; this.observableProvider.stitchLogin(this.loginForm.value).then( (response) => { loader.dismiss(); if (response.success) { localStorage.setItem('email', this.loginForm.value.email); localStorage.setItem('password', this.loginForm.value.password); localStorage.setItem('id', response.data.id); this.navCtrl.setRoot('HomePage'); } else { const alert = this.alertCtrl.create({ title: 'Login failed!', subTitle: response.error, buttons: ['OK'] }); alert.present(); } } ).catch((err) => { loader.dismiss(); const alert = this.alertCtrl.create({ title: 'Something went wrong!', subTitle: err, buttons: ['OK'] }); alert.present(); }); }
private cargarDetalle(vendedor: string, anno: number, mes: number, incluirAlbaranes: boolean, etiqueta: string) { let loading: any = this.loadingCtrl.create({ content: 'Cargando Comisiones...', }); loading.present(); this.servicio.cargarDetalle(vendedor, anno, mes, incluirAlbaranes, etiqueta) .subscribe( data => { if (data.length === 0) { let alert = this.alertCtrl.create({ title: 'Error', subTitle: 'No se han cargado correctamente las comisiones', buttons: ['Ok'], }); alert.present(); } else { this.listaDetalleComision = data; } }, error => { loading.dismiss(); }, () => { loading.dismiss(); } ) }
feedbackSubmit(){ this.loading = this.loadingCtrl.create({ content: 'Please Wait...' }); this.loading.present(); let data = { "subject":this.subject,"remarks":this.remarks, "user_id":this.user_id,"send_file":""} console.log(data); this.apiservice.feedback(data).then((result) => { this.responseData = result; if(this.responseData.status){ this.loading.dismiss(); let toast = this.toastCtrl.create({ message: 'Feedback Submitted Successfully', duration: 5000, position: 'top' }); toast.present(); this.navCtrl.setRoot(this.navCtrl.getActive().component); }else{ this.loading.dismiss(); let toast = this.toastCtrl.create({ message: 'Error! Please send feedback again.', duration: 5000, position: 'top' }); toast.present(); } }); }
loginProject() { let loader = this.loadingCtrl.create({ content: "登录中..." }); loader.present(); if (this.platform.is('android')) { HNBridge.loginProject(() => { loader.dismiss(); HNBridge.gotoPage("project-main"); }, () => { }, this.commonHttpService.accountInfo.account, this.commonHttpService.accountInfo.password); } else { this.projectService.login().subscribe(info => { loader.dismiss(); this.platform.ready().then(() => { HNBridge.setAccountId(info.accountId, parseInt(info.roleId) === 9); HNBridge.gotoPage("project-main"); this.projectService.startGetLocation(); }); }, error => { loader.dismiss(); }); } }
/** * 通用加载提示 * @param msg 提示信息 * @returns 返回加载对象 */ loading(msg:string){ let loader = this.loadCtrl.create({ content: msg, }); loader.present(); return loader; }