Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ionic framework 离子4离子选择基于第一个下拉选择动态生成两个下拉列表,如何清除第二个下拉列表?_Ionic Framework - Fatal编程技术网

Ionic framework 离子4离子选择基于第一个下拉选择动态生成两个下拉列表,如何清除第二个下拉列表?

Ionic framework 离子4离子选择基于第一个下拉选择动态生成两个下拉列表,如何清除第二个下拉列表?,ionic-framework,Ionic Framework,我在ionic项目中有一个表单,它有两个选择ionic select的下拉菜单 当用户在第一个下拉菜单中选择一个选项时,它会在第二个下拉列表中生成选项。这很有效 当我添加新字段时,我可以重新建立第一个列表的值,该列表在.ts中显示为[(ngModel)]=null,但我无法重新建立2下拉列表中的值 , 这是我的标记 <div formArrayName="sucursales" margin-bottom> <!--generate new regis

我在ionic项目中有一个表单,它有两个选择ionic select的下拉菜单

当用户在第一个下拉菜单中选择一个选项时,它会在第二个下拉列表中生成选项。这很有效

当我添加新字段时,我可以重新建立第一个列表的值,该列表在.ts中显示为[(ngModel)]=null,但我无法重新建立2下拉列表中的值

,

这是我的标记

     <div formArrayName="sucursales" margin-bottom>

     <!--generate new registration fields-->
     <section [formGroupName]="i" *ngFor="let tech of   form.controls.sucursales.controls; let i = index">

                <ion-item>
                    <ion-icon name="list" item-start></ion-icon>
                    <ion-label>Departamento</ion-label>
                    <ion-select [(ngModel)]="locate" name="country" #country formControlName="country" (ionChange)="CountryChange($event)">
                        <ion-option *ngFor="let department of ubicacion; let i = index" value="{{department.departamento}}">{{department.departamento}}</ion-option>
                    </ion-select>
                </ion-item>

                <ion-item *ngFor="let x of selectedMunicipality">
                    <ion-icon name="list" item-start></ion-icon>
                    <ion-label>Municipio</ion-label>
                    <ion-select [(ngModel)]="locates" name="state" #state formControlName="state">
                        <ion-option *ngFor="let municipio of x.ciudades" value="{{municipio}}">{{municipio}}</ion-option>
                    </ion-select>
                </ion-item>
我希望第二个离子选择根据第一个离子选择进行选择,如果我动态添加新字段,则新值是独立的。

我最终解决了这个问题

buildGroup(): FormGroup {

return this.fb.group({

selectedSubcategory: [""],
});


CountryChange(value, index:number) {

this.productos.controls[index]selectedMunicipality = this.ubicacion.filter(item =>        item.departamento === value)

    }
和HTML格式

(ionChange)="CountryChange($event,i)"

<ion-item *ngFor="let x of tech.selectedMunicipality">
(ionChange)=“CountryChange($event,i)”
(ionChange)="CountryChange($event,i)"

<ion-item *ngFor="let x of tech.selectedMunicipality">