Search code examples
angularangular-directiverouter-outlet

'router-outlet' is not a known element ANGULAR


I want to configure my route / contact, but when I show the contents of this view with the <router-outlet> </router-outlet> tag, my console displays the following error:

Console

The first thing I did was add this line in my app.module.ts:

import {RouterModule , Routes} from '@angular/router';
import { ContactoComponent } from './contacto/contacto.component';

const routes: Routes = [
  { path: 'contacto', component: ContactoComponent }
];

@NgModule({
  declarations: [
    AppComponent,
    CabezeraComponent,
    FooterComponent,
    ContactoComponent,
    BodyComponent, 
  ],
  exports: [
     RouterModule 
    ],
  imports: [
    BrowserModule,
    RouterModule.forRoot(routes)
  ],
  providers: [],
  bootstrap: [AppComponent],  
})

then in my base route I make the call to a header, a footer and my route with the tag <router-outlet>, the problem is that when I run, my browser goes to target and throws me the error mentioned above in the console. ... this is an error of the version? I am calling the localhost / contact path well, I am currently working with angle 6 .... any help for me?


Solution

  • You need to remove RouterModule under exports

     exports: [
         RouterModule //remove this
     ],