I got an ion-select with different levels, and when I choose one, it shows on the ion-select below the Sub-levels that the level got. When the user changes the level, it needs to restart my data.subLevelId, because if it stays with data, the button to confirm the Register will be valid to use, and when I make this reset on my variable data.subLevelId, all my components bug. Someone know how to fix this? Fallow an example of code below.
// .html
<form [formGroup]="register">
<ion-list>
<ion-item>
<ion-label fixed>Level</ion-label>
<ion-select name="level" formControlName="level" [(ngModel)]="data.levelId" (ionChange)="getSubLevel()">
<ion-option *ngFor="let level of levels" value="{{level.level_id}}">{{level.description}}</ion-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label fixed>Sub level</ion-label>
<ion-select name="subLevel" formControlName="subLevel" [(ngModel)]="data.subLevelId">
<ion-option *ngFor="let subLevel of subLevels" value="{{subLevel.subLevel_id}}" >{{subLevel.subLevel_description}}</ion-option>
</ion-select>
</ion-item>
</ion-list>
<...>
</form>
// .ts
public getSubLevel() {
this.data.subLevelId = null;
this.loadSubLevel();
}
Before
After