错误:未捕获(在承诺中):错误:无法匹配任何路由:'about'

时间:2016-10-04 14:30:05

标签: angular nativescript

我是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"]);

然后我收到错误消息。我错过了什么吗?

谢谢!

1 个答案:

答案 0 :(得分:2)

{
        path        : "about",
        redirectTo  : "/about",
        pathMatch   : "full"
}

将其更改为或添加

{
        path        : "about",
        component   : AboutComponent    //<====whatever component you have. Maybe the relevant component is not found
}