angular - 使用查询字符串参数设置 Angular 6 App Base 启动 URL
问题描述
我需要设置 Angular 6 应用程序的初始启动 URL 以包含查询字符串参数。应用程序配置取决于在启动时获取这些查询字符串参数的值。
它们必须是查询字符串,不能是路径变量。
必须遵循如下模式:localhost:4200/?name=emerfan&ip=123
我尝试过使用路由器和路径,并且尝试使用 Location 在 ngOnInit 方法中重定向 AppComponent,但无济于事。
例如
ngOnInit() {
this._location.replaceState('/?name=emer&ip=123');
}
和
const appRoutes: Routes = [
{ path: '?name=emerfan', component: AppComponent },
{ path: '', redirectTo: '/?name=emerfan', pathMatch: 'full'}];
第一个不起作用,因为应用程序没有重新加载queryStrings来完成配置,第二个不起作用,因为似乎配置已经创建并且在路由重定向发生时没有重新创建..
是否有设置使用查询字符串参数在 Angular 应用程序中设置基本路径?
解决方案
推荐阅读
- c# - 将数据表与 C# 列表进行比较
- android - 是否可以将 SymmetricDS 与 Room Persistence Library 一起使用?
- javascript - 表单验证设置自定义有效性
- wordpress - Fusion builder 在 WordPress 4.9.6 版本中不起作用
- c# - 泛型类型作为委托参数
- python - 如果 pyqtgraph 在 gui 中,则它没有交互模式
- c - C中的这些枚举有什么区别?
- php - PHP:当键具有相同值时合并数组值
- angularjs - Highcharts 回流
- javascript - XMLHttpRequest 不重新加载页面