我无法访问lstTest
,它在console.log(response_testQ.lstTest);
中显示为未定义,但奇怪的是,当我输入console.log(response_testQ);
时,lstTest
显示为Array(3)
。
如何使用forEach(...)在lstTest内部进行迭代?
export class testQ {
lstTest?: Test[];
}
export class Test {
TestId?: number;
}
- 这是我执行的函数 *
Test.SelectAllPaged(request_testQ).subscribe(
{
next: newrow => {
const response_testQ = newrow.response as testQ;
var TableContent: string = "";
console.log(response_testQ);
console.log(response_testQ.lstTest);
response_testQ?.lstTest?.forEach(d => { //HERE IT DOESN'T ENTER
TableContent += `<tr>
<td>
<div class="custom-control">
<input id="Test${d.TestId}" type="checkbox">
</div>
</td>
</tr>`;
})
},
complete: () => {
$(window).on("scroll", ScrollDownNSearch);
console.log("Search finished");
},
error: err => {
console.log("Error during server call. No internet connection?", err)
}
});
1条答案
按热度按时间llmtgqce1#
问题是response_testQ给我的是lstTestModel而不是lstTest