1
Answer

[ERROR] NG8001: 'router-outlet' is not a known element:

Photo of Jocelyn May

Jocelyn May

Nov 28
448
1

Hi

   I am getting below error - 

<nav class="navbar navbar-expand-sm bg-light justify-content-center">
    <ul class="navbar-nav">
      <li class="nav-item">
        <a class="nav-link" routerlink="dashboard">Link 1</a>
      </li>

    </ul>
  </nav>

  <div class="container-fluid mt-3">
    <router-outlet></router-outlet>
  </div>
Markup

 

[ERROR] NG8001: 'router-outlet' is not a known element:
1. If 'router-outlet' is an Angular component, then verify that it is included in the '@Component.imports' of this component.
2. If 'router-outlet' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@Component.schemas' of this component to suppress this message. [plugin angular-compiler]

 

    src/app/Pages/layout/layout.component.html:16:4:
      16 ¦     <router-outlet></router-outlet>

thanks.

Answers (1)

0
Photo of sasikala s
1.1k 585 5.1k Nov 28
import { NgModule } from '@angular\/core';
import { BrowserModule } from '@angular\/platform-browser';
import { RouterModule } from '@angular\/router'; \/\/ Import RouterModule
import { AppComponent } from '.\/app.component';

@NgModule({
  declarations: [
    AppComponent,
    \/\/ other components
  ],
  imports: [
    BrowserModule,
    RouterModule.forRoot([]) \/\/ Initialize routing
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }