policyClicked(policy: Policy){
console.log(policy.name);
this.router.navigate(['/policy',{projectId: this.project._id},{policyName: policy.name}]);
}
Im trying to execute this piece of code to route to the path provided. But i keep getting an error:
Error: Cannot match any routes: 'policy;projectId=uSpGcJFtxHK3vLGht/[object Object]'
Like the last parameter is getting lost or something. I put some logs in there to see if the value is undefined but its there. Heres where the route is defined also.
const routes: RouterConfig = [
{path: '', component: DashBoardHome},
{path: 'project/:projectSearchResultId', component: ProjectSearchResultsDetails},
{path: 'search/:projectSearchValue', component: ProjectSearchResults},
{ path: 'login', component: Login },
{ path: 'signup', component: Signup },
{ path: 'recover', component: Recover },
{path: 'policy/:projectId/:policyName', component: PolicyDetails}
];
In your first example, you're passing an object (the code in braces {}) so Javascript is interpreting it as an [object] which is why you got that strange error. By passing it without braces, Javascript can use the actual text.
You may consider trying it this way, too:
var URL = '/policy/' + this.project._id + '/' + policy.name;
this.router.navigate(URL);