javascript - Angular 2 proper way to template a [routerLink] in a child component -


i trying find way template [routerlink] in child component.

in app.component have have <router-outlet></router-outlet>.

now, inside othermodule.component trying apply <a [routerlink]="['home']">home</a>.

app.module:

import { browsermodule } '@angular/platform-browser'; import { ngmodule } '@angular/core'; import { httpmodule } '@angular/http'; import { appcomponent } './app.component'; import {homemodule} "../home/home.module"; import {othermodule} "../othermodule/othermodule.module"; import {routermodule} "@angular/router"; import {routes} "./routes";  @ngmodule({   declarations: [     appcomponent   ],   imports: [     browsermodule,     homemodule,     httpmodule,     othermodule,     routermodule.forroot(routes)   ],   providers: [],   bootstrap: [appcomponent] }) export class appmodule { } 

routes:

import {homecomponent} "../login/login.component"; import {othercomponent} "../clickstudio/clickstudio.component";  export const routes = [   { path: '', redirectto: 'home', pathmatch: 'full' },   { path: 'home', component: homecomponent },   { path: 'other', component: othercomponent },  ] 

other.component:

import {component} "@angular/core";  @component({   selector: 'other',   template: `<a [routerlink]="['home']">home</a>`,   styleurls: ['./clickstudio-menu.component.scss'] }) export class othercomponent {  } 

my main problem need route root router , not chilren routes

  • what best practices implement this?
  • any way keep binding routerlink?

have tried

<a routerlink="home">details</a> 

or

<a routerlink="/home">details</a> 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -