从Web API获取价值并将其返回到下拉列表

时间:2018-06-28 18:12:21

标签: javascript angular

我正在学习JS / TS,并且遇到以下情况。我不明白函数调用后返回值未出现在下拉列表中的原因。在里面 详细信息字段有效。

我的HTML:

<div class="form-group col-6">
    <label>Details</label>
    <textarea type="text" [(ngModel)]="item.dsDetalhes" formControlName="dsDetalhes" class="form-control"></textarea>
    <div class="validacao" *ngIf="form.get('dsDetalhes').invalid && (form.get('dsDetalhes').dirty || form.get('dsDetalhes').touched)">Campo obrigatório</div>
</div>

<div class="form-group col-1">
    <label for="validationDefault01">Ano</label>
    <select [(ngModel)]="item.nuAno" valuePrimitive="true" formControlName="nuAno" data="lista_ano" type="text" class="form-control">
        <option *ngFor="let nuAno of lista_ano" [ngValue]="nuAno">{{nuAno}}</option>
    </select>
    <div class="validacao" *ngIf="form.get('nuAno').invalid && (form.get('nuAno').dirty || form.get('nuAno').touched)">Campo obrigatório</div>
</div>

我的功能

EditarBoletim(idBoletim: number) {

    this.dbService.post('Boletim/EditarPorId', idBoletim).subscribe(result => {

        this.item = result;

        this.dsDetalhes = result.dsDetalhes //here return some string
        this.nuAno = result.nuAno; //here nuAno return 2015

    });
}

0 个答案:

没有答案