The requirement is very simple. When a Child Route/Component's URL is entered directly in the browser, I should be able to redirect it to the parent route.
Questions :
1. How to identify a page refresh or if a child route is being launched directly?
2. If a child route is launched directly, how do I get its parent route url from the ActivatedRoute object ?
Solution Tried:
I have this following piece of code in my Child Component's OnInit :
this.router.events.subscribe((event) => {
console.log(event);
});
When navigating from a parent route the router events are being logged. But when launching the child URL directly, no events are logged.
Also tried canActivateChild in the route config, but no idea how to determine if a the parent component is loaded ?
Any Help is appreciated. Thanks in Advance!