angular - 如何在 Angular 2 的下拉菜单中使用两种方式绑定概念?
问题描述
我怀疑如何在我尝试过的下拉按钮中使用两种方式绑定概念,但它不起作用。
解决方案
两种方式绑定意味着您只需要[(ngModel)]
在代码中使用这样的变量绑定(如果需要,您可以像使用 as 一样在模板中使用局部变量#businesstype
,否则将其删除) -
<select class="form-control" id="business_type" required [(ngModel)]="update.business_type" name="business_type">
<option disabled>Select</option>
<option *ngFor="let user of users" [value]="user.id">{{user.method}}</option>>
</select>
推荐阅读
- javascript - Vue JS设置填充选择中的第一个项目被选中
- java - Firebase AuthUI - 仅在生产中的未知错误代码
- c# - 使用命名管道在 C# 和 C++ 应用程序之间进行持续通信
- android - 输入提交空,使用nativescript
- android - 获取连接设备地址蓝牙
- elasticsearch - 订购 elasticsearch 聚合
- windows-community-toolkit - 仅在我的项目中使用 Microsoft.Toolkit.Parsers.RssParser
- javascript - Firebase signInWithPopup 不适用于 Firefox - reactjs
- javascript - 第二次验证无效
- mysql - 使用查询将数据库中所有值中字母的第一个单词设为大写