When I bind queryParams
using routerLink
in Angular2, I am getting this error:
[ERROR] Exception while trying to serialize the value
This error is shown when I inspect the DOM. The links simply do not show at all on the page, so this was my only way of debugging since there were no errors in the console either.
Component Code
export class FormatUrlLinkComponent implements OnInit {
@Input('url') apiUrl: string;
@Input('text') linkText: string;
validUrl: {
url: string,
query: object
} = {
url: '',
query: {}
};
constructor() { }
ngOnInit() {
// Format url into a valid url for routerLink
this.validUrl = queryString.parseUrl(this.apiUrl);
console.log(this.validUrl.query);
}
}
Template Code
<a [routerLink]="validUrl.url" [queryParams]="validUrl.query"></a>
When I do a console.log(this.validUrl.query)
I am seeing the following:
{Ntt: "welded"}
Am I doing something wrong here?