My doubt is not about a code of mine but one that I found, it worked for me, but I don't know how it works. It is the following:
let currentUrl = this.router.url;
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
this.router.onSameUrlNavigation = 'reload';
this.router.navigate([currentUrl]);
It works perfectly for what I want, which was to update a single component and not have to update my entire page, since when creating a new object in the database the only way to see it reflected in my page was if I manually reloaded it
RouteReuseStrategy is an Angular provider
One of the abstract classes above is:
Therefore with:
We tell Angular not to reuse the same component object when navigating between routes that reference the same component class.
By giving it the reload value, the route will be reactivated and will not use the same component object, so it will update the component.