Reputation: 2594
With this code using changeDetection: ChangeDetectionStrategy.Default
export class HomePageComponent {
constructor(
private i18nService: I18nService
) {}
get language(): string {
return this.i18nService.language;
}
}
angular update the view but using changeDetection: ChangeDetectionStrategy.OnPush,
it doesn't so the question is:
How can update the view using OnPush?
Upvotes: 0
Views: 1108
Reputation: 391
OnPush will only run change detection once (on creation). And Angular then only triggers change detection when a reference of an @Input() property changes (or if an Event handler of your component gets invoked). In your component I see no @Input() statements at all.
You can manually run change detection by injecting ChangeDetectorRef into your component and calling appropriate methods on it.
Upvotes: 1