在点击功能中检索和显示数组值

时间:2018-08-11 15:23:51

标签: javascript html angular

pro.component.ts

this.vList.forEach((v: any) => {
            v.Completed ? this.trainCom++ : this.trainpen++;
            v.isQCompleted ? this.qCount++ : this.qPen++;
          });
        });
        this.vList.forEach((v: any) => {
          if(!v.Completed) {
            this.pen_cour.push(v.name);
          } else {
            this.com_cour.push(v.name);
          }
          if(!v.isQCompleted) {
            this.pen_cour_q.push(v.name);
          } else {
            this.com_cour_q.push(v.name);
          }
        });
      });
cour_Com(){
    this.com_cour.forEach(element => {
      this.cour1 =this.com_cour;
      console.log("hello");
      console.log(this.cour1);
    });
  }

pro.component.html

<button type="button" class="btn btn-primary" (click)="cour_Comp()" >View</button>
  <div id="demo" *ngFor='let cour of this.com_cour'>
    <span *ngIf="this.com_cour != NULL"><button type="button" class="btn btn-primary" ng-show="this.com_cour != NULL">{{course}}</button></span>
  </div>

0 个答案:

没有答案