I have a routerlink in a in Angular. I am trying to send some data along with the routerlink. This is the html code of the component:
html code:
<a routerLink="/register" [queryParams]="{ selRole: 1 }">Register Now</a>
In my component:
ngOnInit() {
this.route.queryParams
.subscribe(params => {
this.selRole = params['selRole'] || 0;
});
console.log(this.selRole)
}
But I always keep getting a 0. What exactly am I doing wrong here?