Answer the question
In order to leave comments, you need to log in
Subscribe to the route?
Hello colleagues. I need your help. I've already broken my head.
I have a method for copying data from a form.
I am on the form No. 1, I press the button, the data is copied from the form and go to another route (form No. 2). It all works.
But if I need to copy the data and go to the same form, the route does not work.
In 1 case, I subscribe to params changes. this.route.params
What can be done to somehow track if params has not changed.
Answer the question
In order to leave comments, you need to log in
You either need to change the route, for example, by adding a hash or query param
. Or turn off component reuse, then the component will be re-initialized on each click. By placing this somewhere above, for example in app.component
constructor(
private router: Router,
) {
this.router.routeReuseStrategy.shouldReuseRoute = function () {
return false;
};
this.router.events.subscribe((evt) => {
if (evt instanceof NavigationEnd) {
this.router.navigated = false;
}
});
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question