angularjs – Angular 2 Rc.1路由器未加载“/”组件

我试图使用rc.0版本中的新路由器. (实际使用rc.1)但是我无法获得加载“欢迎”组件的插座.

这是app.component.ts

import { Component } from '@angular/core';
import { Routes,ROUTER_DIRECTIVES} from '@angular/router';
import { HeaderComponent } from './common/header.component';
import { WelcomeComponent } from './common/welcome.component';
import { FooterComponent } from './common/footer.component';

@Component({
  selector: 'my-app',template: `
    <header-component> </header-component> 
        <router-outlet> </router-outlet> 
    <footer-component> <footer-component> 
  `,directives: [ROUTER_DIRECTIVES,HeaderComponent,WelcomeComponent,FooterComponent]
})

@Routes([
    {path: "/",component: WelcomeComponent}
]) 

export class AppComponent { 


}

这是main.ts

import { bootstrap }    from '@angular/platform-browser-dynamic';
import {ROUTER_PROVIDERS} from '@angular/router';
import { AppComponent } from './app.component';

bootstrap(AppComponent,[ROUTER_PROVIDERS]);

我不确定我失踪了什么,/应该工作的路径. index.html的基本引用也设置为“/”.我一直在挖掘源头,看看我遗失了什么,但没有找到任何东西.

这是一个已知问题 https://github.com/angular/angular/issues/8409

If you have routes setup without any router links and you don’t inject the router,initial navigation does not occur.

因此要么注入路由器,要么添加< a [routerLink] =“...”>直到此问题得到解决.

相关文章

ANGULAR.JS:NG-SELECTANDNG-OPTIONSPS:其实看英文文档比看中...
AngularJS中使用Chart.js制折线图与饼图实例  Chart.js 是...
IE浏览器兼容性后续前言 继续尝试解决IE浏览器兼容性问题,...
Angular实现下拉菜单多选写这篇文章时,引用文章地址如下:h...
在AngularJS应用中集成科大讯飞语音输入功能前言 根据项目...
Angular数据更新不及时问题探讨前言 在修复控制角标正确变...