In my case, I had a very similar problem. insert ChangeDetectorRef and call cdRef.detectChanges ()
Therefore, the code should be like this:
import {Component, OnInit, ChangeDetectorRef} from 'angular2/core';
export class RecentDetectionComponent implements OnInit, OnDestroy {
constructor(private cdRef: ChangeDetectorRef // <== added ) {
}
allClicked(){
if(this.isAll){
console.log(this.isAll)
this.isAll = false;
for (let temp of this.students)
{
temp.checked = false;
}
}else{
this.isAll = true;
for (let temp of this.students) {
temp.checked = true;
}
}
console.log("all select event ");
this.cdRef.detectChanges();
}
}
source
share