我使用Angular2 alpha39和Babel来转换ES6 JS文件.我没有使用打字稿.
我创建了一个正确显示的组件.我在模板上添加了一个路由器插座.当我运行应用程序时,我收到错误消息:
没有路由器提供商!(RouterOutlet - >路由器)
调用堆栈是:
以下是代码片段:
模板:
.... // Removed for brevity
<div class="contenttext">
<router-outlet></router-outlet>
</div>
.... // Removed for brevity
Run Code Online (Sandbox Code Playgroud)
组件文件:
import { Component, View, bootstrap, OnInit } from 'angular2/angular2';
import { RouteConfig, RouterOutlet, RouterLink } from 'angular2/router';
import 'reflect-metadata';
import 'winjs';
@Component({
selector: 'dashboard-app'
})
@View({
templateUrl: '../js/dashboard.html',
directives: [ ContentComponent, FamiliesComponent, RouterOutlet, RouterLink ]
})
@RouteConfig([
{ path: '/employees', component: EmployeesComponent, as: 'employees'}
])
class DashboardAppComponent implements OnInit {
constructor() …Run Code Online (Sandbox Code Playgroud)