angular2如何选择全部?

时间:2017-04-14 06:34:26

标签: angular rxjs

class Heroe{
    selected ?: boolean;
}    


heroes: Observable<Heroe[]>
....
this.heroes = this.heroService.getHeroes()
....
select_all(){
    How to do it?
}

=======

<div *ngFor="let hero of heroes | async" >
  <span *ngIF="hero.selected">selected</span>
  {{hero.name}}
</div>
<input type="checkbox" #checkbox (change)="select_all(checkbox.checked)">

如何选择? 如何选择? 如何选择? 如何选择? 如何选择? 如何选择?

1 个答案:

答案 0 :(得分:0)

this.heroes = this.heroes.map(heroes => heroes.map(hero => ({...hero, selected})));