代码: 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>