Search code examples
angulartypescriptangular4-router

How to get back to HomeComponent in angular 4?


Router modules

RouterModule.forRoot([
  { 
    path: "",
    component: HomeComponent
  },
  { 
    path: "edit/:id",
  component: EditComponent
}
])

Html button

<button [routerLink] = "">Cancel</button>

Above is my router module and html button. I am not able to redirect to HomeComponent. How to achieve it? TIA.


Solution

  • <a routerLink="/"><button class="btn btn-default" >Cancel</button></a>