I got the following error with my code.
"Cannot set property 'elements' of undefined"
Code looks like this:
this.languages.forEach((value, index) => {
debugger
this.languageTableElement = { type: 'checkbox'}
this.languageTableRows[index].elements.push(this.languageTableElement)
})
The question is: How to define the elements
?
Ok, i reconized how to do it, the answer is simple:
this.languageTableRows = [];
this.languages = await this.languageService.getAllLanguages().toPromise();
this.languages.forEach((value, index) => {
this.languageTableRows[index] = new TableRowModel;
this.languageTableRows[index].elements = [];
this.languageTableElement = { type: 'checkbox'}
this.languageTableRows[index].elements.push(this.languageTableElement)
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.