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() {
  }

}
3
  • Any error in console ? Commented Jan 23, 2020 at 9:27
  • 1
    Is it the same with that ? <a [routerLink]="['/deviceapps']">Name</a> Commented Jan 23, 2020 at 9:27
  • @SameerKhan - Cannot match any routes. URL Segment: 'devicelist/96/deviceapps' Commented Jan 23, 2020 at 9:29

2 Answers 2

2

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

<a [routerLink]="'/deviceapps'">{{lst.Name}}</a>
Sign up to request clarification or add additional context in comments.

Comments

1

Use square bracket

 <a [routerLink]="'/path'">
    {{lst.Name}}
 </a>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.