1 回答

TA貢獻1827條經驗 獲得超9個贊
你應該循環li不上ul。它也可以以更簡單的方式完成。
你應該這樣做:
在component.ts文件中,按如下方式處理您的數據:
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>
添加回答
舉報