I am trying to create a onClick function, such that when a button is clicked it navigates to another page with the id of the selected function. However whenever i run the following code i get in console:
ERROR Error: The requested path contains undefined segment at index 1
component.ts:
constructor(private damageAssessmentService: DamageAssessmentReportService, private router: Router, private route: ActivatedRoute) {}
oneDAFormID: string;
onView(){
this.damageAssessmentService.getOneDAForm(this.oneDAFormID)
this.route.params.subscribe((params: Params)=> {
this.oneDAFormID = params['getDAId'];
console.log(this.oneDAFormID);
//navigate to /view-full-daform/_id
this.router.navigate(['/view-full-daform' , this.oneDAFormID])
})
}
Service:
getOneDAForm(getDAId: any){
return this.webReqService.get(`DamageAssessmentForm/${getDAId}`);
}
Webservice:
get(uri: string) {
return this.http.get(`${this.ROOT_URL}/${uri}`)
I don't quite know how to get the id from the page and navigate to the other page so i can implement the id in the ngOnInit(). Any assistance would be appreciate