我是Angular2 + Nativescript + TypeScript的新手,我正在尝试重现我的cordova应用程序。我正试图从登录页面导航到关于页面,我收到此错误:
Error: Uncaught (in promise): Error: Cannot match any routes: 'about'
在我的app.routes.ts
文件中,我有以下代码:
import { Routes } from "@angular/router";
export const appRoutes: Routes = [
{
path: "",
redirectTo: "/login",
pathMatch: "full"
},
{
path: "about",
redirectTo: "/about",
pathMatch: "full"
}
];
然后,在我的login.component.ts中,我尝试使用路由器实例导航到about页面:
this.router.navigate(["/about"]);
然后我收到错误消息。我错过了什么吗?
谢谢!
答案 0 :(得分:2)
{
path : "about",
redirectTo : "/about",
pathMatch : "full"
}
将其更改为或添加
{
path : "about",
component : AboutComponent //<====whatever component you have. Maybe the relevant component is not found
}