Am new to angular2 and am looking forward to add parameters to a router when the current url doesnt have the said param on click event
This is what i have tried
The button
<button (click)="onStats()">Proceed to stats </button>
Now the function
onStats(){
let url = this.router.url;
//here i would like to check if the router constains ?stats
//am stuck
}
So basically i have my urls as
locahost:4200/users/roles
localhost:4200/managers
...............
now i would like to add ?stats at the end of url if it doesnt exists hence the new url to be
locahost:4200/users/roles?stats
locahost:4200/managers?stats
...........
In my routing i have setup
{path:'user/roles:stats' , component:UserRolesStats}
How do i go about it
I would not like to hardcode the routerlink="users/roles?stats" since other areas also use this stats functionalities as well