angular - uirouter update optional param without reload -


i have angular 4 app multiple routes (ui-router) accept optional params.

{ name: 'shirts', url:'/shirts/:color/:size, component: shirtcomponent } 

this works want change of optional params on click of button. without reloading entire page. looking way update params in url.

i have spend hours looking solution there many angular 1 answers , don't wiser docs.

help appreciated.

you use location api's go/replacestate method belongs @angular/common. replace browser history without letting router know it.

import { location } '@angular/common';  export class mycomponent {     constructor(private location: location) { }     redirect(){         this.location.go('/mypath');         //or         //this.location.replacestate('/mypath');     } } 

demo here


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -