3
「タイプに存在しません」というエラーがスローされます私はhttp://localhost:3001/?foobar=1236Angular2 queryParamsが
import { Injectable } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import 'rxjs/add/operator/map';
@Injectable()
export class ParameterService {
constructor(private route: ActivatedRoute) { }
getParameter() {
return this.route.snapshot.queryParams.foobar;
}
}
のようなURLからパラメータを返す必要がありAngular2サービスだ。しかし、私は私が得るサービスのgetParameterで()メソッドを呼び出したときエラー:
error TS2339: Property 'foobar' does not exist on type '{ [key: string]: any; }'
エラーが発生した後、正しい結果が返されます。デバッガでfoobarパラメータに問題なくアクセスできます。誰かが同様の問題を抱えていましたか?私はそれが早く呼び出されると想像することができますか?
(可能性の重複:angular2 rc6: Property queryParams does not exist on type RouterState)
おかげで男を!私は2分後にそれを見つけました...常に同じ: –