У меня есть 2 выпадающих списка, один для выбора штат , а другой для сервисное агентство . Параметры, отображаемые для сервисного агентства , зависят от состояния выбранного значения.
Данные для обслуживающего агентства и state раскрываются из profile.service.ts
.
Проблема: Как изменить значение, отображаемое в сервисном агентстве, когда пользователь выбирает состояние.
profile.component.html
<mat-form-field>
<mat-select placeholder="Service Agency" required formControlName="serviceAgency">
<mat-option value="option">Option</mat-option>
<mat-option value="{{item.id}}" *ngFor="let item of service_agency$">
{{item.name}}
</mat-option>
</mat-select>
</mat-form-field>
profile.component.ts
//get state
get_state(){
this.profileService.get_state().subscribe(data => {
this.state$ = data;
});
}
//get service center base on state id
onChange(state) {
this.service_agency$ = this.profileService.get_service_agency()
.pipe(filter((item)=> item == state.value));
console.log(this.service_agency$);
}
profile.service.ts
get_state() {
return this.http.get(url)
.pipe(map(data => {
return data;
}));
}
get_service_agency() {
return this.http.get(url)
.pipe(map(data => {
return data;
}));
}