Angular 2 is not updating the UI when making changes to a variable/model in Node
That's probably caused by fs.readdir
. It seems it is using an API that is not patched by Angulars zone. To work around you can use
export class FilesComponent {
constructor(private cdRef:ChangeDetectorRef) {}
loadFiles() {
fs.readdir(this.cwd, (err, dir) => {
for (let filePath of dir) {
console.log(filePath);
this.files.push(filePath);
}
this.cdRef.detectChanges();
});
}
}