How to perform some replaceWith
to the same route but with a different parameter?
The route declaration is:
this.route('sampleRoute', { path: '/:param_name' });
This 'sampleRoute' route reproduces the problem: the URL does not changes after a replaceWith
inside it.
let globalFlag = null;
export default Route.extend({
afterModel() {
console.log("welcome");
if(globalFlag){
console.log(this.router.location.getURL());
console.log(this.paramsFor(this.routeName).param_name);
} else {
globalFlag = true;
this.replaceWith(this.routeName, 'progValue');
}
}
});
Tried with beforeModel, model, afterModel. How to have the URL properly set before running some code?
Testing this route with http://localhost/sampleRoute/browserValue produces:
Expected output:
welcome
welcome
/sampleRoute/progValue
progValue
Actual output:
welcome
welcome
/sampleRoute/browserValue
progValue
Aucun commentaire:
Enregistrer un commentaire