私は奇妙な問題に直面しました。私はクラスを持っている:Typescriptがプロパティタイプを変更しましたか?
export class Example: {
str: string;
isActive: boolean;
}
その後、私は私がこれをやっている子コンポーネントで... routerLink
とqueryParams
を経由して別のコンポーネントからそのクラスのいくつかのデータを転送:
this.activatedRoute.params.subscribe((params: Example) => {
console.log(params, typeof params.isActive); //outputs string!!
});
//output: {str: "xxx", isActive: "true"}, "string"
ファーストその後、私は、コントローラでそれを実行しようとしました、
[routerLink]="['/my/route', row]"
を:私はように、テンプレートにqueryParamsを送っ
onBtnClick(row: Example) {
console.log(row, typeof row.isActive);
this.router.navigate(['/my/route'],{queryParams: row});
}
//output: {str: "xxx", isActive: true}, "boolean"
どうしてこの問題を解決するのですか?
エラーは何ですか? – Chandru
ブール型プロパティisActiveはどのように 'string'になりましたか? – Daria