【发布时间】:2019-12-05 13:04:24
【问题描述】:
尝试在 html 中绘制类时出现此错误
<li>
<ul>
<li *ngFor="let refac of refactormodel" >
-- word_to_rename: {{refac.word_to_rename}}
-- renowned_word: {{refac.renowned_word}}
-- name: {{refac.name}}
</li>
</ul>
</li>
我希望如果类是空的,我不绘制它,但是是的,并且在绘制时它会给出错误: ERROR 错误:尝试区分“nombreyo”时出错。只允许使用数组和可迭代对象
private refactormodel : getrefactormodel[] = [];
....
this.authService.getrefactor().subscribe((res : getrefactormodel[])=>{
this.refactormodel = res;
});
getrefactor() {
return this.http.get(apiUrl + 'getRules');
}
重构模型.ts:
export interface getrefactormodel {
word_to_rename: String;
renowned_word: String;
name: String;
}
【问题讨论】:
标签: angular typescript httpclient angular8