HTML未在选择中绑定

时间:2019-02-27 06:08:42

标签: angular6

在component.ts中:

optionhtml:any='';
this.optionhtml='<option value="1">Option1</option>';
this.optionhtml+='<option value="2">Option2</option>';
this.optionhtml+='<option value="3">Option3</option>';

在component.html中:

<select class="custom-select mr-sm-2 choose-category" [(ngModel)]="category"  id="inlineFormCustomSelect" [ngModelOptions]="{standalone: true}" (change)="filterbycategory(category)" [innerHTML]="optionhtml" >
<select>

选项未使用innerHTML绑定到“选择”框中

1 个答案:

答案 0 :(得分:0)

为什么要从打字稿中传递字符串?而是创建集合或数组对象并将其绑定到html