Angular 为什么routerLink失败?

Angular 为什么routerLink失败?,angular,angular2-routing,Angular,Angular2 Routing,目标: 使用navbar.component.html中的链接: 应用程序 问题: 我得到错误:原始异常:RouterOutletMap没有提供程序 上下文: navbar.component.ts 从'@angular/core'导入{Component}; 从'@angular/Router'导入{Router,RouterOutlet,RouterLink}; @组成部分({ moduleId:module.id, 选择器:“导航栏”, templateUrl:'navbar.comp

目标:

使用
navbar.component.html
中的链接:

应用程序
问题:

我得到错误:
原始异常:RouterOutletMap没有提供程序


上下文:

navbar.component.ts

从'@angular/core'导入{Component};
从'@angular/Router'导入{Router,RouterOutlet,RouterLink};
@组成部分({
moduleId:module.id,
选择器:“导航栏”,
templateUrl:'navbar.component.html',
样式URL:['navbar.component.css'],
指令:[路由器输出,路由器链接]
})
导出类导航组件
{
版本:字符串;
版本可视:布尔值;
路由器:路由器;
构造器(路由器:路由器){
this.version='';
this.router=路由器;
}
}
应用程序组件.ts

从'@angular/core'导入{Component,ViewEncapsulation};
从“./navbar/navbar.component”导入{NavbarComponent};
从“./application/application.component”导入{ApplicationComponent};
从“./Config/env.Config”导出{Config};
@组成部分({
moduleId:module.id,
选择器:“应用程序”,
templateUrl:'app.component.html',
样式URL:['app.component.css'],
封装:视图封装。无,
指令:[NavbarComponent,ApplicationComponent]
})
导出类AppComponent
{
构造函数(){
//log('Environment config',config);
}
}
应用程序路由.ts

从'@angular/core'导入{ModuleWithProviders};
从'@angular/router'导入{Routes,RouterModule};
从“./application/application.component”导入{ApplicationComponent};
导出常量路由:路由=[
{路径:'',组件:ApplicationComponent},
{路径:“应用程序”,组件:ApplicationComponent},
{path:'signin',组件:ApplicationComponent},
{路径:'profile',组件:ApplicationComponent},
{路径:“帮助”,组件:ApplicationComponent},
{path:'view/settings/:key',component:ApplicationComponent},
//{路径:'**',组件:PageNotFoundComponent},
];
导出常量批准提供程序:任意[]=[
];
导出常量路由:ModuleWithProviders=RouterModule.forRoot(路由);
应用程序模块.ts

从'@angular/core'导入{ModuleWithProviders};
从“./app.component”导入{AppComponent};
从“/app.routes”导入{routes,ApprovingProviders};
@NGD模块({
进口:[
浏览器模块,
FormsModule,
路线
],
声明:[
应用组件,
],
供应商:[
认可供应商
],
引导:[AppComponent]
})
package.json

“依赖项”:{
“@angular/common”:“2.0.0-rc.5”,
“@angular/compiler”:“2.0.0-rc.5”,
“@angular/core”:“2.0.0-rc.5”,
“@angular/forms”:“0.3.0”,
“@angular/http”:“2.0.0-rc.5”,
“@angular/platform浏览器”:“2.0.0-rc.5”,
“@angular/platform browser dynamic”:“2.0.0-rc.5”,
“@angular/router”:“3.0.0-rc.1”,
“核心js”:“^2.4.0”,
“es6模块加载器”:“^0.17.8”,
“吞咽缩小css”:“^1.2.4”,
“狼吞虎咽”:“^2.3.2”,
“gulp sourcemaps”:“^2.0.0-alpha”,
“rxjs”:“5.0.0-beta.6”,
“systemjs”:“0.19.27”,
“zone.js”:“0.6.13”
}
应该是

@NgModule({
    imports: [
        BrowserModule,
        FormsModule,
        routing // <== change
@NgModule({
进口:[
浏览器模块,
FormsModule,

路由//您在何处以及如何初始化路由器和路由?我添加了app.routes.ts。这有帮助吗?您是否在
@NgModule()中导入
ModuleWithProviders
?是的。我现在已经包括了app.module.ts供您查看。您是否使用webpack,那么这可能会有所帮助,否则我想我已经没有主意了。我将
路由的两个实例更改为
路由
,但仍然得到了
路由输出图的无提供者!
。不确定它是否相关,但我也得到了
app.module.ts(22,3):错误TS1146:需要声明。
,但我看不到错误。为什么是两个实例。是否有子路由(其他模块中的路由)?两个,因为它发生在这里
导入{routes,approvingProviders}从“/app.routes”;
和您指定的位置。我还尝试仅更改您指定的实例,但结果相同。
@NgModule({
    imports: [
        BrowserModule,
        FormsModule,
        routing // <== change