Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有没有办法判断Angular 8中的RouterModule useHash是否设置为true?_Angular_Angular Ui Router_Angular2 Routing_Hash Location Strategy - Fatal编程技术网

有没有办法判断Angular 8中的RouterModule useHash是否设置为true?

有没有办法判断Angular 8中的RouterModule useHash是否设置为true?,angular,angular-ui-router,angular2-routing,hash-location-strategy,Angular,Angular Ui Router,Angular2 Routing,Hash Location Strategy,我正在为我的工作开发一个库,它允许其他开发团队使用我们的一些角度组件,并传入它们自己的配置。其中一个是RouterModule 我在库中找到了一些代码,需要确定它们是否在模块配置中启用了heuseHash:true参数 @NgModule({ imports: [RouterModule.forRoot(routes, { useHash: true })], exports: [RouterModule], }) 我真正需要做的就是看看它是否被设置为true、false或null,但

我正在为我的工作开发一个库,它允许其他开发团队使用我们的一些角度组件,并传入它们自己的配置。其中一个是RouterModule

我在库中找到了一些代码,需要确定它们是否在模块配置中启用了he
useHash:true
参数

@NgModule({
  imports: [RouterModule.forRoot(routes, { useHash: true })],
  exports: [RouterModule],
})
我真正需要做的就是看看它是否被设置为true、false或null,但我一直在梳理文档并搜索谷歌,我被难倒了

我尝试了一些简单的方法,但这当然不起作用

constructor(private route: ActivatedRoute, private router: Router, private module: RouterModule) {
   console.log(router.useHash)
}

有人知道这是可能的吗?

答案来得晚,但可能对某些人仍然有用

constructor(private platformLocation: PlatformLocation) {
}

useHash() {
  return this.platformLocation.hash?.indexOf('#') > -1;
}