4

I'm using Angular 4 to create my admin panel. To the left, I have a menu loaded from the primary Router. To the left is a greenish area where I want to load another component. I used a new router named "console-router". However, I can't get the content to show. The other component has valid HTML inside, and the primary router works great. I'm getting a parse error when defining the (link) that is supposed to show the "App Dashboard" content in the area to the left.

Screenshot of the console

I have defined my paths in the App Module:

app.module.ts

{
 path: 'console',
 component: ConsoleComponent,
 children: [
    {
        path: 'dashboard',
        component: AppDashboardComponent,
        outlet: 'console-router'
    }
 ]
}

Here is the link that is supposed to load the component when "App Dashboard" is clicked:

console.component.html

<li><a [routerLink]="[{ outlets: { console-router: ['dashboard'] } }]">App Dashboard</a></li>

This is the definition of the Router inside the Console.

console.component.html

<router-outlet name="console-router"></router-outlet>

This is the error I'm getting (As if it was a syntax error, but in Angular.io, the code is exactly the same):

enter image description here

3
  • Are you importing the RouterModule into your module? Commented Jun 27, 2017 at 18:07
  • @Derked in the main module (Where all the paths are defined) i have: import { RouterModule, Routes } from '@angular/router'; Commented Jun 27, 2017 at 18:09
  • All other paths work just fine (The ones on the primary Router). Commented Jun 27, 2017 at 18:11

1 Answer 1

3

Well, for anyone getting a parse error on a named router. The router can't have a hyphen ( - ) in its name. This is just the way Routers are defined in Angular as of this version.

Thanks!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.