按返回按钮时,“角度6”复选框值丢失。我对所有表单都使用了路由。除复选框外,所有其他输入类型均可正常工作。当我按下后退按钮时,单选按钮保持原值,但所有复选框的值均未选中。
.html `
<form #ingredientForm="ngForm" class="editForm" novalidate>
<div class="card space-wrap">
<div class="card--content" *ngFor = "let data of options">
<input type="checkbox" #ingredient[data.name]="ngModel" required [(ngModel)]="ingredientType[data.name]" value="{{data.name}}" name="select" id="{{data.name}}"/>
<label for="{{data.name}}">{{data.name}}</label>
</div>
</div>
<button type="button" [disabled]=disable (click)="goToNext(ingredientForm)" class="btn btn-mobile btn-primary btn-fixed">Next: Ingredients</button>
</form>
This is my form model ingredient is used for checbox
export class FormData {
finger: string = '';
chocolate: string = '';
ingredient: any = {};
message: string = '';
packaging: string = '';
clear() {
this.finger = '';
this.chocolate = '';
this.ingredient = '';
this.message = '';
this.packaging = '';
}
}
`