-1
我的部件構造我現在做這樣在我的構造函數:我怎樣才能從URL參數使用ActivatedRoute
this.articleSlug = _route.url._value[1].path;
打字稿,但不喜歡它:
Property: "_value" does not exist on type Observable<Params>
有更清潔的方法嗎?我在使用TypeScript和webpack的Angular 4。
這是當我使用:_route:ActivatedRoute在我的構造。
您可以展開*「不喜歡它」*嗎? – jonrsharpe
我在 – AngularM
上面添加了錯誤我假設'_route'是ActivatedRoute類型?如果是這樣,你可以嘗試:'this._route.queryParams.subscribe(params => {this.articleSlug = params ['yourParameter'] ||''});' – eminlala