Hi all,
I am trying to use the Loading component but I have problem trying to manually dismiss the Loading dialog.
LoginPage is a Modal
import {IonicApp, Page, NavController, ViewController, Loading} from 'ionic-angular';
import {User} from '../../providers/user';
import {DashboardPage} from '../dashboard/dashboard';
@Page({
templateUrl: 'build/pages/login/login.html'
})
export class LoginPage {
static get parameters() {
return [[NavController], [User], [ViewController]];
}
constructor(nav, user, viewCtrl) {
this.nav = nav;
this.user = user;
this.viewCtrl = viewCtrl;
// Loading component
this.loading = Loading.create({
content: "Authenticating. . ."
});
this.login = {};
this.submitted = false;
}
onLogin(form) {
this.submitted = true;
if (form.valid) {
this.nav.present(this.loading);
if (this.user.login(this.login.username, this.login.password)) {
//this.loading.dismiss();
this.viewCtrl.dismiss();
this.nav.setRoot(DashboardPage);
}
else {
this.loading.dismiss(); // << this is giving problems.
}
}
}
dismiss(data) {
// using the injected ViewController this page
// can "dismiss" itself and pass back data
this.viewCtrl.dismiss(data);
}
}
LoginPage html
<ion-navbar *navbar>
<ion-buttons start>
<button (click)="dismiss()"><ion-icon ios="ios-close"></ion-icon></button>
</ion-buttons>
<ion-title>Sign In</ion-title>
<ion-buttons end>
<button (click)="onLogin(loginForm)">Login</button>
</ion-buttons>
</ion-navbar>
<ion-content>
<ion-list>
<form #loginForm="ngForm" novalidate>
<p class="text first">Use this email address to sign in</p>
<ion-item>
<input class="text-input" [(ngModel)]="login.username" placeholder="email address" ngControl="username" type="text" #username="ngForm" required autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">
</ion-item>
<p [hidden]="username.valid || submitted == false" danger padding-left>
Username is required
</p>
<p class="text second">Use this password to sign in</p>
<ion-item>
<input class="text-input" [(ngModel)]="login.password" placeholder="password" ngControl="password" type="password" #password="ngForm" required autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">
</ion-item>
<p [hidden]="password.valid || submitted == false" danger padding-left>
Password is required
</p>
</form>
</ion-list>
</ion-content>
Error
[Error] EXCEPTION: Error during evaluation of "click"
logError (app.bundle.js:31475)
logGroup (app.bundle.js:31485)
call (app.bundle.js:29225)
(anonymous function) (app.bundle.js:13947)
(anonymous function) (app.bundle.js:28724)
__tryOrUnsub (app.bundle.js:73914)
next (app.bundle.js:73863)
_next (app.bundle.js:73822)
next (app.bundle.js:73799)
_finalNext (app.bundle.js:73674)
_next (app.bundle.js:73666)
next (app.bundle.js:73623)
emit (app.bundle.js:28713)
onError (app.bundle.js:28400)
onHandleError (app.bundle.js:28584)
handleError (angular2-polyfills.js:394)
runGuarded (angular2-polyfills.js:300)
runInner (app.bundle.js:28594:82)
run (app.bundle.js:28501)
outsideHandler (app.bundle.js:32717)
invokeTask (angular2-polyfills.js:423)
runTask (angular2-polyfills.js:320)
invoke (angular2-polyfills.js:490)
dispatchEvent
touchEnd (app.bundle.js:55874)
(anonymous function)
[Error] ORIGINAL EXCEPTION: TypeError: undefined is not an object (evaluating 'leavingView.pageRef().nativeElement')
logError (app.bundle.js:31475)
call (app.bundle.js:29234)
(anonymous function) (app.bundle.js:13947)
(anonymous function) (app.bundle.js:28724)
__tryOrUnsub (app.bundle.js:73914)
next (app.bundle.js:73863)
_next (app.bundle.js:73822)
next (app.bundle.js:73799)
_finalNext (app.bundle.js:73674)
_next (app.bundle.js:73666)
next (app.bundle.js:73623)
emit (app.bundle.js:28713)
onError (app.bundle.js:28400)
onHandleError (app.bundle.js:28584)
handleError (angular2-polyfills.js:394)
runGuarded (angular2-polyfills.js:300)
runInner (app.bundle.js:28594:82)
run (app.bundle.js:28501)
outsideHandler (app.bundle.js:32717)
invokeTask (angular2-polyfills.js:423)
runTask (angular2-polyfills.js:320)
invoke (angular2-polyfills.js:490)
dispatchEvent
touchEnd (app.bundle.js:55874)
(anonymous function)
[Error] ORIGINAL STACKTRACE:
logError (app.bundle.js:31475)
call (app.bundle.js:29237)
(anonymous function) (app.bundle.js:13947)
(anonymous function) (app.bundle.js:28724)
__tryOrUnsub (app.bundle.js:73914)
next (app.bundle.js:73863)
_next (app.bundle.js:73822)
next (app.bundle.js:73799)
_finalNext (app.bundle.js:73674)
_next (app.bundle.js:73666)
next (app.bundle.js:73623)
emit (app.bundle.js:28713)
onError (app.bundle.js:28400)
onHandleError (app.bundle.js:28584)
handleError (angular2-polyfills.js:394)
runGuarded (angular2-polyfills.js:300)
runInner (app.bundle.js:28594:82)
run (app.bundle.js:28501)
outsideHandler (app.bundle.js:32717)
invokeTask (angular2-polyfills.js:423)
runTask (angular2-polyfills.js:320)
invoke (angular2-polyfills.js:490)
dispatchEvent
touchEnd (app.bundle.js:55874)
(anonymous function)
[Error] LoadingPopOut@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/app.bundle.js:42745:40
createTransition@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/app.bundle.js:62742:35
file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/app.bundle.js:45238:74
invoke@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/angular2-polyfills.js:390:34
run@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/angular2-polyfills.js:283:50
runOuter@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/app.bundle.js:28596:74
runOutsideAngular@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/app.bundle.js:28514:88
_beforeTrans@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/app.bundle.js:45228:37
_postRender@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/app.bundle.js:45210:26
_render@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/app.bundle.js:45126:29
_transition@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/app.bundle.js:45098:21
remove@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/app.bundle.js:44959:29
dismiss@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/app.bundle.js:46551:32
onLogin@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/app.bundle.js:472:26
handleEventInternal
handleEvent@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/app.bundle.js:14300:48
triggerEventHandlers@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/app.bundle.js:24129:47
file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/app.bundle.js:32639:48
file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/app.bundle.js:32717:93
invoke@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/angular2-polyfills.js:390:34
onInvoke@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/app.bundle.js:28563:47
invoke@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/angular2-polyfills.js:389:43
runGuarded@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/angular2-polyfills.js:297:54
runInner@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/app.bundle.js:28594:81
run@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/app.bundle.js:28501:74
outsideHandler@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/app.bundle.js:32717:64
invokeTask@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/angular2-polyfills.js:423:43
runTask@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/angular2-polyfills.js:320:58
invoke@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/angular2-polyfills.js:490:41
dispatchEvent@[native code]
touchEnd@file:///Users/shawnang/Library/Developer/CoreSimulator/Devices/05D02343-6E70-4EB1-94F1-88011A0C2E7A/data/Containers/Bundle/Application/1EBD5207-9521-43C6-AE2D-D43D18CBED90/SAM.app/www/build/js/app.bundle.js:55874:44
[native code]
logError (app.bundle.js:31475)
call (app.bundle.js:29238)
(anonymous function) (app.bundle.js:13947)
(anonymous function) (app.bundle.js:28724)
__tryOrUnsub (app.bundle.js:73914)
next (app.bundle.js:73863)
_next (app.bundle.js:73822)
next (app.bundle.js:73799)
_finalNext (app.bundle.js:73674)
_next (app.bundle.js:73666)
next (app.bundle.js:73623)
emit (app.bundle.js:28713)
onError (app.bundle.js:28400)
onHandleError (app.bundle.js:28584)
handleError (angular2-polyfills.js:394)
runGuarded (angular2-polyfills.js:300)
runInner (app.bundle.js:28594:82)
run (app.bundle.js:28501)
outsideHandler (app.bundle.js:32717)
invokeTask (angular2-polyfills.js:423)
runTask (angular2-polyfills.js:320)
invoke (angular2-polyfills.js:490)
dispatchEvent
touchEnd (app.bundle.js:55874)
(anonymous function)