数组的元素未在angular5中正确迭代

时间:2018-08-03 06:36:40

标签: html angular5

  • 我正在尝试通过单击功能在不同数组下使用angular5分配和显示数组元素
  • 但是每个元素都显示在html组件中,但未使用click fucntionality
  • 我提供了相关代码,并请您提出相同的建议

代码: a.component.ts

List: any = ["1", "2", "3", "4", "5"];
completed: any = [];
pending: any = [];

this.List.forEach((v: any) => {
            if(v%2 == 0) {
              this.pending.push(v);
            } else {
              this.completed.push(v);
            }
          });

a.component.html

<div id="demo" *ngFor='let cour of this.completed'>
    <span *ngIf="this.completed != NULL"><button type="button" class="btn btn-primary" ng-show="this.completed != NULL">{{cour}}</button></span>
  </div>

0 个答案:

没有答案