[英]Default “placeholder” of Select-box in Angular?
I'm developing a web application (front-end size) using Angular 6. I have a question: I'm creating a component that contains different select-box, like this: 我正在使用Angular 6开发一个Web应用程序(前端大小)。我有一个问题:我正在创建一个包含不同选择框的组件,如下所示:
How can I create a reset()
method that changes all the select-box with the placeholder value (without canceling or modifying the options associated with him in any way)? 如何创建一个用占位符值更改所有选择框的
reset()
方法(不以任何方式取消或修改与他相关的选项)? Is there any way that allows this by modifying the html template programmatically? 有什么方法可以通过以编程方式修改html模板来允许此操作吗? Thanks!
谢谢!
you can use ngModel
您可以使用
ngModel
<select class="custom-select" [(ngModel)]="model.select" name="select" id="combo">
<option value=""></option>
<option *ngFor="let item of list" [ngValue]="item">{{ item}}</option>
</select>
component: 零件:
reset(){
model.selct='';
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.