【发布时间】:2020-09-24 12:01:03
【问题描述】:
是否可以在服务器端获取查询参数? 我有我的 Angular 应用程序的 Lambda Cloudfront 部署版本。
当平台浏览器发生时,一切正常。
当我尝试在服务器端获取查询参数时,我总是得到 null/undefined。
我试过这个:
ngOnInit(): void {
this.queryId = this.route.snapshot.queryParamMap.get('id');
this.metaPlatform.addTag({ property: this.queryId, content: this.queryId });
}
//I get this meta tag:
<meta property="null" content="null">
也试过这个:
ngOnInit(): void {
const snapshot = this.router.routerState.snapshot;
this.meta.addTag({property: snapshot.url.split('=')[1],content: snapshot.url.split('=')[1]);
}
//I get this meta tag:
<meta property="undefined" content="undefined">
我想根据 queryParams 设置元标记,但我找不到将它们放在服务器端的方法。
【问题讨论】:
标签: angular server-side-rendering angular-universal query-parameters