2016-10-04 101 views
0

我是Angular2 + Nativescript + TypeScript中的新成员,我试图重现我的cordova应用。我试图从导航登录页面关于页面,我得到这个错误:错误:未被捕获(承诺):错误:无法匹配任何路由:'about'

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 ,我尝试使用路由器实例导航到关于页面:

this.router.navigate(["/about"]); 

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

谢谢!

回答

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

其更改或添加它,

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

我已经试过了,这是我所得到的:组件AboutComponent没有任何NgModule或模块的一部分没有被导入到你的模块。 – relez

+0

好的。为了更多的代码是需要的。你在哪里使用router-outlet? – micronyks

+0

我使用Visual Studio和Telerik AppBuilder工具,它在app文件夹中创建多个文件:app.component.ts,app.modules.ts,app.routes.ts,main.ts.我猜你正在问的路由器插座是在app.component.ts中: @Component({ns-main}, template:““, }) – relez

相关问题