angular2 rc1:没有RouterOutletMap的提供程序 [英] angular2 rc1: No provider for RouterOutletMap

查看:61
本文介绍了angular2 rc1:没有RouterOutletMap的提供程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在组件内创建了一个子组件.我还创建了相应的路线.现在,执行完此操作后,最初由angular-cli创建的测试将失败,并显示以下信息:

I created a subcomponent within a component. I also created the according routes. Now after I did this, the test that was originally created by angular-cli fails with:

没有提供RouterOutletMap的提供商!

No provider for RouterOutletMap!

此错误消息是否有一般原因?我总是可以发布整个组件的源代码,但是在这一点上,这似乎有些过分了:-)

Is there any general reason for this error-message? I could always post the whole component-sourcecode, but that seems overkill at this point :-)

编辑:我正在使用新路由器(rc1)

I am using the new router (rc1)

推荐答案

确保在主AppComponent中使用了以下5点-

Make sure you have used following 5 points in your main AppComponent-

import { ROUTER_PROVIDERS, Routes, ROUTER_DIRECTIVES, Router } from '@angular/router';


directives: [ROUTER_DIRECTIVES],


providers: [ROUTER_PROVIDERS]


@Routes([
    { path: '/', component: WelcomeComponent },


export class AppComponent {
        constructor(private router: Router) {} 
}

在index.html中,您有<base href="/">

And in index.html, you have <base href="/">

<!DOCTYPE html>
<html>

<head lang="en">
    <base href="/">
    <title>Acme Product Management</title>

看看这是否有帮助.

这篇关于angular2 rc1:没有RouterOutletMap的提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆