如何在Angular中设置url参数 4
How to set url parameters in Angular 4
我一直在寻找为这种 url 设置参数的方法,但我做不到
http://localhost:9111/v1/companies/{公司}/用户
其中 {Company} 是参数
有人知道如何为此 url 设置参数吗?
您可以轻松使用 template literals!
let company = 'google';
return this.http.get(`http://localhost:9111/v1/companies/${company}/users`);
稍作更新
直接跳到这个部分可能会更快:https://angular.io/docs/ts/latest/guide/router.html#!#link-parameters-array
原创
阅读 angular 文档的这一部分应该会详细解释您要执行的操作:https://angular.io/docs/ts/latest/guide/router.html#!#route-def-with-parameter
在您的路由模块中,您以 ~ { path: 'v1/companies/:companyId/users', component: TheComponent }
的形式定义路由
我一直在寻找为这种 url 设置参数的方法,但我做不到
http://localhost:9111/v1/companies/{公司}/用户
其中 {Company} 是参数
有人知道如何为此 url 设置参数吗?
您可以轻松使用 template literals!
let company = 'google';
return this.http.get(`http://localhost:9111/v1/companies/${company}/users`);
稍作更新
直接跳到这个部分可能会更快:https://angular.io/docs/ts/latest/guide/router.html#!#link-parameters-array
原创
阅读 angular 文档的这一部分应该会详细解释您要执行的操作:https://angular.io/docs/ts/latest/guide/router.html#!#route-def-with-parameter
在您的路由模块中,您以 ~ { path: 'v1/companies/:companyId/users', component: TheComponent }