这是我的Typescript文件,可以在其中成功获取数据,但是DOM无法正确更新。如果我在其他地方单击,它将更新,数据将反映在我的字段中。
如果我注释所有内容,然后像这样{{buttonstate.name}}直接绑定我的数据,那么就不会出现延迟,流程可以很好地工作。
buildmultipleButton(button, state) {
this.singlebtnlst = [];
let data = {
id: this.statementId,
...button,
data: {
...state,
chatbot_id: this.botingId,
},
expressions: [],
var_name: ""
}
this.cos.buildApi(data)
.then(data => {
if (data['response']['data']['type'] === "multi_select") {
this.multiplebtnlst = data['response']['meta_data'];
this.multiplebtnlst.push({ id: 0, botUp_id_id: 0, name: "Please Enter Something !" });
} else if (data['response']['data']['type'] === "button") {
this.singlebtnlst = data['response']['meta_data']['button'];
this.singlebtnlst.push({ id: 0, botUp_id_id: 0, name: "Please Enter Something !" });
}
this.getstatementlist(this.id);
})
.catch(console.log)
}
这是获取数据时不会更新的HTML文件
<div class="form-group popover-buttons"
*ngFor="let buttonstate of multiplebtnlst; let i= index">
<input formControlName="mc_btn"
(change)="updatesubbutton($event.target.value)" type="text"
[value]="buttonstate.name"
style="width:86% !important; float:left; margin-bottom:10px;"
class="form-control morebuttoninpt multipleinptarray">
<button *ngIf="buttonstate.id != 0"
type="button" class="btn btn-primary btn-sm ml5 removesnglebtn"
(click)="multiplebtnremove(buttonstate.id)">
<i class="fa fa-minus"></i>enter code here
</button>
<span (click)="addmultiplebtn(buttonstate.id)">
<i style="cursor:pointer; float: right; padding: 8px 8px;"
class="fa fa-plus btn btn-primary addsnglebtn">
</i>
</span>
</div>