I am attempting to retrieve the current URL in Angular 8 using
this._my.dialog = location.pathname.replace('/', '');
, but it is not consistently returning the desired result, even when placed within ngOnInit()
.
This issue seems to occur most notably when:
- Modifying the URL
- Loading for the first time
In my app.component.html file, I have the following structure:
<app-nav-menu></app-nav-menu>
<div class="container">
<router-outlet></router-outlet>
<app-myAppForGettingTheURL></app-myAppForGettingTheURL>
</div>
Could someone guide me on how to achieve this correctly?