1

I have 3 component from 1st moving to 2nd. But from 2nd I am not able to navigate 3rd component.

Name showing only hyperlink but when clicking nothing happens.

This is 2nd component code

<table>
<tr *ngFor="let lst of devices; let i = index" border="1">
  <td>{{lst.DeviceId}}</td>
  <td>{{lst.LastJobStatus}}</td>
  <td> <a routerLink="deviceapps">{{lst.Name}}</a> </td>
</tr>
</table>

App-routing.module.ts class

const routes: Routes = [
  { path: 'devicelist/:id', component: DeviceListComponent } ,
  {path: 'deviceapps',component: DeviceAppsComponent}
];

3rd component code

import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router, ParamMap } from '@angular/router';

@Component({
  selector: 'app-device-apps',
  templateUrl: './device-apps.component.html',
  styleUrls: ['./device-apps.component.css']
})
export class DeviceAppsComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }

}
R15
  • 13,982
  • 14
  • 97
  • 173

2 Answers2

2

It looks like you are using relative paths inside, so try to write absolute routing like:

<a [routerLink]="'/deviceapps'">{{lst.Name}}</a>
Roy
  • 7,811
  • 4
  • 24
  • 47
StepUp
  • 36,391
  • 15
  • 88
  • 148
1

Use square bracket

 <a [routerLink]="'/path'">
    {{lst.Name}}
 </a>
JohnMathew
  • 508
  • 1
  • 5
  • 21