I have a component where I have a list of objects and I want to pass in a single input parameter that describes the route that should be navigated to when any specific row is clicked.
Something like the below:
//Some sort of object may have an 'id' field in some cases (but not in other cases... if it didn't I would pass in a different string below)
@Input()
listData: any[];
@Input()
link: string; // Input of something like "/List/Detail/${row.id}"
rowClick(row: any){
//Grab row.id and interpolate it so result is "/List/Detail/1"
???
router.navigate([url]);
}
Seems like it should be simple, but I'm having a hard time wrapping my head around it.
The idea here is that my list items will sometimes link to one page and sometimes link to a different page depending on the 'link' parameter.
${row.url}/${row.id};