it is me again.... I have problems displaying my array of items in the view, i always get this error. [Unhandled Promise rejection: Cannot set property 'stack' of undefined ; Zone: ; Task: Promise.then ; Value: TypeError: Cannot set property 'stack' of undefined]
Maybe i'm doing something wrong when it comes to the binding of the data in the html view.
ngOnInit() : void{
this._loadCoil.getAllCoils().subscribe(coils =>{ this.coils = coils;
this.gridData = {
data: this.coils.slice(this.currentPage, this.currentPage + this.displaySize),
total: this.coils.length};
for(let i = 0; i < this.coils.length; i++){
let isFound = false;
for (let j = 0; j < this.dropDownArray.length; j++){
if (this.dropDownArray[j] == this.coils[i].unit){
isFound = true;
break;
}
}
if(!isFound){
this.dropDownArray.push(this.coils[i].unit);
}
}
});
}
Basically i want to fill my array with unit names and display them on the website. (This part is working fine)
However, when i want to print the names on a page i get the before mentioned here. Here is my code snippet from the html page
<div>
<ul>
<li *ngFor="let name in dropDownArray">{{name}}</li>
</ul>
</div>
而不是in
,它应该是of
在迭代:
<li *ngFor="let name of dropDownArray">{{name}}</li>
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.