Angular 2无法在html页面中显示项目列表

Pro*_*oxy 2 javascript angular2-template angular

它又是我....我在视图中显示我的项目数组时遇到问题,我总是遇到这个错误.[Unhandled Promise rejection:无法设置未定义的属性'stack'; 区域:; 任务:Promise.then; 值:TypeError:无法设置未定义的属性'stack']

也许我在html视图中绑定数据时做错了.

   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);
                }
            }
        }); 

    }
Run Code Online (Sandbox Code Playgroud)

基本上我想用我的数组填充单位名称并在网站上显示它们.(这部分工作正常)

但是,当我想在页面上打印名称时,我得到前面提到的.这是我在html页面中的代码片段

  <div>
         <ul>
           <li *ngFor="let name in dropDownArray">{{name}}</li>
         </ul>

  </div>
Run Code Online (Sandbox Code Playgroud)

AJT*_*T82 5

而不是in,它应该of在迭代中:

<li *ngFor="let name of dropDownArray">{{name}}</li>
Run Code Online (Sandbox Code Playgroud)