我使用console.log(_router.url)
时无法获取网址。它只返回/
(斜杠)
当我执行以下代码时:
constructor(
private el: ElementRef,
private _auth:AuthenticationService,
@Inject(AppStore) private store: Store<AppState>,
private _router:Router,
) {
console.log(_router);
console.log(_router.url);
}
单击(...)时会显示"/languages"
但是当我console.log(_router.url)
这只是打印
答案 0 :(得分:2)
答案 1 :(得分:2)
这是我的代码:
// This is important because when you use Location in the constructor it
// gets accepted but the wrong library is used.
import { Location } from '@angular/common';
export class MainComponent {
constructor(public location: Location) {
console.log(this.location.path());
}
}