I have an issue in Angular2 (final) around change detection and data flow between components. I have worked around it but it seems a little hacky to me so was wondering if t
You can inject private cdRef:ChangeDetectorRef
and call this.cdRef.detectChanges()
at the end of ngOnChanges()
. This way Angular runs change detection again and won't complain about previously modified model values.
class MyComponent {
constructor(private cdRef:ChangeDetectorRef) {}
ngOnChanges(changes) {
this.xxx = ...
...
this.cdRef.detectChanges();
}
}