Tobias Gassmann
Tobias Gassmann

Reputation: 11829

angular2 rc1: No provider for RouterOutletMap

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:

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 :-)

Edit: I am using the new router (rc1)

Upvotes: 0

Views: 1134

Answers (1)

Sanket
Sanket

Reputation: 20037

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) {} 
}

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

<!DOCTYPE html>
<html>

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

See if this helps.

Upvotes: 1

Related Questions