My issue lies in the router link within company-details.component.html:
<a class="btn btn-white btn-xs" [routerLink]="['/companyDetails', nextCompanyID]">
The path specified in my app.module.ts file is as follows:
{ path: 'companyDetails/:companyID', component: CompanyDetailsComponent },
In company-details.component.ts, I have imported the necessary modules:
import { ActivatedRoute, Router, RouterModule, Routes } from "@angular/router";
nextCompanyID: number;
I have also set the value of nextCompanyID to 2 in the constructor.
Currently, I am at http://localhost:55588/companyDetails/1. When I click the button to navigate, the URL changes to http://localhost:55588/companyDetails/2, but no lifecycle events are triggered. The view data remains unchanged.
What steps do I need to take for the routing to function properly?
The resulting element generated by the router link looks correct to me:
<a class="btn btn-white btn-xs" ng-reflect-router-link="/companyDetails,2" href="/companyDetails/2"><i class="fa fa-chevron-right"></i></a>
Could there be an issue with the routerLink? I have referred to the documentation () and made sure to follow the requirements mentioned there.
If you use dynamic values to generate the link, you can pass an array of path segments, followed by the params for each segment.
I believe I have met this requirement. What else could be missing?
Your assistance would be greatly appreciated.