Reputation: 141
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:
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?
Upvotes: 1
Views: 186
Reputation: 271
Try with this:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule, Routes } from '@angular/router';
@NgModule({
imports: [
BrowserModule,
RouterModule.forRoot(routes)
],
declarations: [
AppComponent,
CabezeraComponent,
FooterComponent,
ContactoComponent,
BodyComponent,
],
bootstrap: [AppComponent]
})
export class AppModule {
}
There is no need to configurate the exports in AppModule
, because AppModule
wont be imported by other modules in your application.
Upvotes: 1
Reputation: 222522
You need to remove RouterModule
under exports
exports: [
RouterModule //remove this
],
Upvotes: 0