我在Ionic中與this.nav.push
存在問題。我已經完成了登錄/註冊頁面,但是當我登錄時,我收到了此錯誤消息。我必須從login.ts添加代碼,例如home.ts(這是主頁)?Ionic未捕獲(承諾):無效鏈接
Runtime Error
Uncaught (in promise): invalid link: HomePage
Error: Uncaught (in promise): invalid link: HomePage at d (http://localhost:8100/build/polyfills.js:3:3991) at l (http://localhost:8100/build/polyfills.js:3:3244) at Object.reject (http://localhost:8100/build/polyfills.js:3:2600) at NavControllerBase._fireError (http://localhost:8100/build/main.js:45465:16) at NavControllerBase._failed (http://localhost:8100/build/main.js:45453:14) at http://localhost:8100/build/main.js:45508:59 at t.invoke (http://localhost:8100/build/polyfills.js:3:11562) at Object.onInvoke (http://localhost:8100/build/main.js:4622:37) at t.invoke (http://localhost:8100/build/polyfills.js:3:11502) at n.run (http://localhost:8100/build/polyfills.js:3:6468) at http://localhost:8100/build/polyfills.js:3:3767 at t.invokeTask (http://localhost:8100/build/polyfills.js:3:12256) at Object.onInvokeTask (http://localhost:8100/build/main.js:4613:37) at t.invokeTask (http://localhost:8100/build/polyfills.js:3:12177) at 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', '[email protected]');
observer.next(access);
observer.complete();
});
}
}
我不知道爲什麼這段代碼是錯誤的。我的主頁INY我的應用程序是home.ts和類是首頁
歡迎來到StackOverflow!爲了讓我們更好地爲您提供幫助,請更新您的問題,以便以[**最小,完整和可驗證的示例**](http://stackoverflow.com/help/mcve)顯示所有相關代碼。如果您能讓我們知道您迄今爲止已經嘗試解決您的問題,也會有所幫助。有關詳細信息,請參閱有關[**如何提出良好問題**](http://stackoverflow.com/help/how-to-ask)的幫助文章,並參加該網站的[**遊覽**](http://stackoverflow.com/tour):) –