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)">
如何选择? 如何选择? 如何选择? 如何选择? 如何选择? 如何选择?
答案 0 :(得分:0)
this.heroes = this.heroes.map(heroes => heroes.map(hero => ({...hero, selected})));