ルーティングボタンから[queryParams]="{'usd':usd, 'count' :country, 'name' :name}"
を使用して、あるページから別のルーティングページにデータを渡そうとしています。それは完全に動作していますが、私のコンソールにエラーがあります。ルータリンクでデータを送信
import {Component, OnInit} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
@Component({
selector: 'app-hairstylist-profile',
templateUrl: './hairstylist-profile.component.html',
styleUrls: ['./hairstylist-profile.component.css'],
})
export class HairstylistProfileComponent implements OnInit {
name;
usd;
count;
constructor(private route: ActivatedRoute) {
}
ngOnInit() {
const usd = this.route.queryParams.value.usd;
this.usd = usd;
const count = this.route.queryParams.value.count;
this.count = count;
const name = this.route.queryParams.value.name;
this.name = name;
}
}
値キーワードにエラーがある:
ERROR in src/app/hairstylist-profile/hairstylist-profile.component.ts(18,40): error TS2339: Property 'value' does not exist on type 'Observable<Params>'.
src/app/hairstylist-profile/hairstylist-profile.component.ts(20,42): error TS2339: Property 'value' does not exist on type 'Observable<Params>'.
src/app/hairstylist-profile/hairstylist-profile.component.ts(22,41): error TS2339: Property 'value' does not exist on type 'Observable<Params>'.
この
は私のコードです。それでどうやって解決できるの?
エラーメッセージを読んでください。あなたはパラームを持っていない、あなたはそれらの観察可能な*を持っています。 – jonrsharpe
[angle2のURLからどのようにクエリパラメータを取得するのですか?](https://stackoverflow.com/questions/35688084/how-get-query-params-from-url-in-angular2) –