问题描述
我的代码有问题。 所以我试图制作一个表单来接收来自用户的信息并将其添加到组件的属性中。为此,我使用了 2 路绑定,以及一些输入和选择。 我的选择正在接收来自枚举的选项。 问题是,当我在输入或选择中使用 ngModel 时,我的选择选项消失了。
<div class="container">
<div class="form">
<input type="text" placeholder="Brand" [(ngModel)]="newItem.brand" />
<input type="text" placeholder="Model" [(ngModel)]="newItem.model" />
<input type="text" placeholder="Price" [(ngModel)]="newItem.price" />
<textarea
placeholder="Description"
[(ngModel)]="newItem.description"
></textarea>
<select class="form-control" [(ngModel)]="newItem.genre">
<option value="" disabled selected>Gender</option>
<option *ngFor="let genre of genres.select()" value="{{ genre.key }}">
{{ genre.value }}
</option>
</select>
<select class="form-control" [(ngModel)]="newItem.notes">
<option value="" disabled selected>Notes</option>
<option *ngFor="let note of notes.select()" value="{{ note.key }}">
{{ note.value }}
</option>
</select>
<select class="form-control" [(ngModel)]="newItem.size">
<option value="" disabled selected>Size of bottle</option>
<option *ngFor="let size of sizes.select()" value="{{ size.key }}">
{{ size.value }}
</option>
</select>
<select class="form-control" [(ngModel)]="newItem.type">
<option value="" disabled selected>Type</option>
<option *ngFor="let type of types.select()" value="{{ type.key }}">
{{ type.value }}
</option>
</select>
<input
type="text"
placeholder="Img URL"
[(ngModel)]="newItem.image"
/>
</div>
<button class="btn">CREATE</button>
</div>
我真的不知道我做错了什么或其他方式来做到这一点。 如果你们能帮助我,那就太好了!
提前致谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)