URL參數我一直在尋找方法來設置參數爲這種網址,但我不能如何設置角4
http://localhost:9111/v1/companies/ {}公司/用戶
其中{}公司是參數
任何人都有如何爲這個網址設置參數的想法?
URL參數我一直在尋找方法來設置參數爲這種網址,但我不能如何設置角4
http://localhost:9111/v1/companies/ {}公司/用戶
其中{}公司是參數
任何人都有如何爲這個網址設置參數的想法?
您可以輕鬆使用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
原
讀繞角文檔的本節應詳細說明什麼你正在嘗試做:https://angular.io/docs/ts/latest/guide/router.html#!#route-def-with-parameter
在您的路由模塊中,您以〜{ path: 'v1/companies/:companyId/users', component: TheComponent }
的形式定義路由這需要使用反引號,而不是單引號。 – Muirik
@Muirik你是對的!打字太快的人 – CozyAzure