【发布时间】:2017-03-11 01:24:44
【问题描述】:
例如。我在浏览器中有网址,即http://localhost:2000/#/?userName=john
我想访问应用程序中的 url,并喜欢在应用程序中使用用户名数据。
我正在使用带有 typescript 的 angular2
【问题讨论】:
标签: angular typescript
例如。我在浏览器中有网址,即http://localhost:2000/#/?userName=john
我想访问应用程序中的 url,并喜欢在应用程序中使用用户名数据。
我正在使用带有 typescript 的 angular2
【问题讨论】:
标签: angular typescript
你可以使用
this.foo = this.route.snapshot.queryParams['userName']
要访问该值,但您必须设置ActivatedRouteSnapshot 和RouterStateSnapshot。
详细了解queryParams 以及如何在the official documentation at Angular.io 上进行设置。
【讨论】: