Reena Lakra

Reena Lakra

  • NA
  • 146
  • 53.9k

Unable to get Id by routing in Angular 4

May 4 2018 5:05 AM
Hello,
 
I didn't get student id in my ts file by routing, 
 
Student.html file contains :
  1. <table>  
  2.   <tr><th>ID</th><th>Name</th><th>Age</th></tr>  
  3.   <tr *ngFor="let record of StudentList">  
  4.     <td><a [routerLink]="['/students',record.ID]">{{record.ID}}</a></td>  
  5.     <td>{{record.Name}}</td>  
  6.     <td>{{record.Age}}</td>  
  7.   </tr>  
  8. </table>  
Student.component.ts file : 
  1. this._activatedRoute.params.subscribe(params => {  
  2.         this.studentId = params['StudId'];   
  3.  });  
Routing file contains  
  1. {path:'students/:StudId',component:StudentComponent}  

Answers (4)