Angular 在“角度6”中动态选择选项

Angular 在“角度6”中动态选择选项,angular,select,Angular,Select,如何在Angular 6中动态选择选项?该页面有许多selects,如图所示: 如果某个选项的值等于parcela.forma\u parcela,我如何动态选择该选项的值 parcela.forma_parcela=[0,1,2,3,4,5,6] <select (change)="setBancoParcela($event.target.value, parcela)" class="input-default" name="forma_pagamento_1" id="forma

如何在Angular 6中动态选择
选项
?该页面有许多
select
s,如图所示:

如果某个选项的值等于
parcela.forma\u parcela
,我如何动态选择该选项的值

parcela.forma_parcela=[0,1,2,3,4,5,6]

<select (change)="setBancoParcela($event.target.value, parcela)" class="input-default" name="forma_pagamento_1" id="forma_pagamento_1">
    <option value="0" [selected]="parcela.forma_parcela == this.value">Banco</option>
    <option value="1" [selected]="parcela.forma_parcela == this.value">BNDES</option>
    <option value="2" [selected]="parcela.forma_parcela == this.value">Boleto</option>
    <option value="3" [selected]="parcela.forma_parcela == this.value">Cartão de Crédito</option>
    <option value="4" [selected]="parcela.forma_parcela == this.value">Cartão de Débito</option>
    <option value="5" [selected]="parcela.forma_parcela == this.value">CH Descontado</option>
    <option value="6" [selected]="parcela.forma_parcela == this.value">Cheque</option>
    <option value="7" [selected]="parcela.forma_parcela == this.value">DDA</option>
    <option value="8" [selected]="parcela.forma_parcela == this.value">Débito Automático</option>
    <option value="9" [selected]="parcela.forma_parcela == this.value">Depósito em C/C</option>
</select>

银行
BNDES
博莱托
卡托·德克雷迪托酒店
卡托德比托酒店
陈德康塔多
支票
DDA
德比托汽车公司
副首席执行官

您可以使用ngModel指令,并从类中导出选项。

我用:
{{{forma.nome}}
创建动态的正确方法是:

<select id="select-type-basic" [(ngModel)]="status">
    <option *ngFor="let status_item of status_values">
    {{status_item}}
    </option>
</select>
试试这个

 <select
       class="custom-select"
       name="ratings"
       [ngModel]="ratings.OverallRating">
       <option 
        *ngFor="let orc of ratings?.RatingChoices"
         [value]="orc.ratingChoice">
         {{orc.ratingDescription}}
       </option>
    </select>

{{orc.ratingDescription}}

我正在从DB获取数据,现在我需要将正确的选项值设置为“item(parcela)”-在页面中有很多选择,请参见图片@Danillo如果您有1000个选择标记,您可以使用推荐的ngModel。看看这个:我用:{{forma.nome}解决了这个问题
 <select
       class="custom-select"
       name="ratings"
       [ngModel]="ratings.OverallRating">
       <option 
        *ngFor="let orc of ratings?.RatingChoices"
         [value]="orc.ratingChoice">
         {{orc.ratingDescription}}
       </option>
    </select>