In my Angular Route, I define that I'm using Hash strategy:
// app-routing-module.ts
@NgModule({
imports: [
RouterModule.forRoot(routes, {
useHash: true
})
],
//...
When I want to test the current Router url, I run this code:
import { Router } from '@angular/router';
// ..
constructor(private _router: Router) {}
getUrl() {
return this._router.url; // always return '/'
}
The this._router.url is always equal to '/'. However, if I test window.location.href, I'm getting a different value (the real full url).
How do I get the current router-url (in the Angular way, not via window object) while using Hash Strategy?