【发布时间】:2017-10-13 15:32:46
【问题描述】:
Ionic 中的this.nav.push 可能有问题。我已经完成了登录/注册页面,但是当我登录时,我收到此错误消息。我必须在 login.ts 中添加一些代码,例如 home.ts(这是主页)?
运行时错误
未捕获(承诺):无效链接:主页
错误:未捕获(承诺):无效链接:主页 在 d (http://localhost:8100/build/polyfills.js:3:3991) 在 l (http://localhost:8100/build/polyfills.js:3:3244) 在 Object.reject (http://localhost:8100/build/polyfills.js:3:2600) 在 NavControllerBase._fireError (http://localhost:8100/build/main.js:45465:16) 在 NavControllerBase._failed (http://localhost:8100/build/main.js:45453:14) 在http://localhost:8100/build/main.js:45508:59 在 t.invoke (http://localhost:8100/build/polyfills.js:3:11562) 在 Object.onInvoke (http://localhost:8100/build/main.js:4622:37) 在 t.invoke (http://localhost:8100/build/polyfills.js:3:11502) 在 n.run (http://localhost:8100/build/polyfills.js:3:6468) 在http://localhost:8100/build/polyfills.js:3:3767 在 t.invokeTask (http://localhost:8100/build/polyfills.js:3:12256) 在 Object.onInvokeTask (http://localhost:8100/build/main.js:4613:37) 在 t.invokeTask (http://localhost:8100/build/polyfills.js:3:12177) 在 n.runTask (http://localhost:8100/build/polyfills.js:3:7153)
@edit:当我想登录我的应用程序时会出现问题。这是登录代码。
login.ts
public login() {
this.showLoading()
this.auth.login(this.registerCredentials).subscribe(allowed => {
if (allowed) {
this.nav.push('HomePage');
} else {
this.showError("Access Denied");
}
},
error => {
this.showError(error);
});
}
auth-service.ts(这里是执行我的登录的公共函数,我有密码和电子邮件,我需要输入登录信息)
public login(credentials) {
if (credentials.email === null || credentials.password === null) {
return Observable.throw("Please insert credentials");
} else {
return Observable.create(observer => {
// At this point make a request to your backend to make a real check!
let access = (credentials.password === "pass" && credentials.email === "email");
this.currentUser = new User('Simon', 'saimon@devdactic.com');
observer.next(access);
observer.complete();
});
}
}
我不知道为什么这段代码是错误的。我的应用程序中的主页是 home.ts,类是 HomePage
【问题讨论】:
-
欢迎来到 StackOverflow!为了让我们更好地帮助您,请更新您的问题,以便它在 minimal, complete, and verifiable example 中显示所有相关代码。如果您能告诉我们您迄今为止为解决问题所做的尝试,这也会很有帮助。如需更多信息,请参阅有关how to ask good questions 的帮助文章,并使用tour of the site :)
标签: ionic3