1 回答

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超9個(gè)贊
你應(yīng)該循環(huán)li不上ul。它也可以以更簡(jiǎn)單的方式完成。
你應(yīng)該這樣做:
在component.ts文件中,按如下方式處理您的數(shù)據(jù):
callGenerateConfig() {
let data = [];
data = this.globalJsonData.parent.child;
let position = 1;
data.forEach((item, index) => {
let isLabel = item.QuestionTypeId === 18;
console.log(isLabel);
let obj = {
label: isLabel,
data: item,
location: position
}
if (!isLabel) {
position++;
}
this.questionList.push(obj);
})
}
在component.html下面做:
<ul>
<li *ngFor="let data of questionList">
<span *ngIf="data.label===false"> {{data.location}}</span>
<span> {{data.data.QuestionText}}</span>
</li>
</ul>
添加回答
舉報(bào)