Reputation: 41571
I am developing the first Angular 2 application and have the following code
AppModule.ts code
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {RouterModule} from '@angular/router';
import { AppComponent } from './app.component';
import { MenuComponent} from './home/menu/menu.component';
import { FooterComponent} from './home/footer/footer.component';
import { AboutComponent} from './personalDetails/about/about.component';
@NgModule({
imports: [
BrowserModule,
RouterModule.forRoot([
{path: '' , component : AboutComponent},
{path: 'about' , component : AboutComponent}
])
],
declarations: [
AppComponent,
MenuComponent,
FooterComponent,
AboutComponent,
],
bootstrap: [ AppComponent ]
})
export class AppModule { }
AppComponent.ts code
import { Component } from '@angular/core';
@Component({
selector: 'app',
template: `
<menu></menu>
<router-outlet></router-outlet>
<footer></footer>
`
})
export class AppComponent { }
My console says the following error
Upvotes: 2
Views: 4894
Reputation: 41571
The fix is simple and I forgot to add the base href tag in the index.html,
<base href="/"/>
When I researched why should we add base href by default which is not the case in angular1. I found the following
Upvotes: 3