如何从 angular 5 中的查询字符串中读取值?

How do I read the values from query string in angular 5?

如何从 angular 5

中的查询字符串中读取值

url格式如下 https://www.test.com/test?id=13467tdgbgfhjfgy

在您的组件中,您可以使用 A​​ctivatedRoute 访问查询参数。

constructor(private route: ActivatedRoute) { }

ngOnInit() {
  this.route.queryParams.subscribe(params => {
    console.log(params['id']); // 13467tdgbgfhjfgy
  });
}

https://alligator.io/angular/query-parameters/