Arnold Arnold - 9 months ago 41
TypeScript Question

How to use routerlink in angular2?

I am trying to redirect from one page to another using routerlink and I had tried the following code,

I have the following route as my url


I want to redirect to this,when i click on this

[routerLink]=" ['tables/basic'] "


but it is going to


Here dashboard should be removed and how can I do that? Can anyone pls provide some help?

my routes.ts,

import { Routes } from '@angular/router';
import { ErrorComponent } from './error/error.component';

export const ROUTES: Routes = [{
path: '', redirectTo: 'app', pathMatch: 'full'
}, {
path: 'app', loadChildren: () => System.import('./layout/layout.module')
}, {
path: 'login', loadChildren: () => System.import('./login/login.module')
}, {
path: 'error', component: ErrorComponent
}, {
path: '**', component: ErrorComponent

Answer Source





To be sure you would need to provide the information what routes your application has configured and what component contains the [routerLink]