Reputation: 857
In my app.component
i have have the <router-outlet></router-outlet>
.
Now, inside otherModule.component
I am trying to apply a <a [routerLink]="['home']">Home</a>
.
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import {HomeModule} from "../home/home.module";
import {OtherModule} from "../otherModule/otherModule.module";
import {RouterModule} from "@angular/router";
import {routes} from "./routes";
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
HomeModule,
HttpModule,
OtherModule,
RouterModule.forRoot(routes)
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
import {HomeComponent} from "../login/login.component";
import {OtherComponent} from "../clickStudio/clickStudio.component";
export const routes = [
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{ path: 'other', component: OtherComponent },
]
import {Component} from "@angular/core";
@Component({
selector: 'other',
template: `<a [routerLink]="['home']">Home</a>`,
styleUrls: ['./clickstudio-menu.component.scss']
})
export class OtherComponent {
}
Upvotes: 0
Views: 951
Reputation: 2068
Have you tried
<a routerLink="home">Details</a>
or
<a routerLink="/home">Details</a>
Upvotes: 3