Created
May 7, 2020 10:56
-
-
Save robertdempsey/a87b411d9c7be0164908ef5a9642e298 to your computer and use it in GitHub Desktop.
Triggers change detection with OnPush strategy even if it is manually triggered from outside.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, EventEmitter, Input, Output, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core'; | |
@Component({ | |
selector: 'display', | |
templateUrl: './display.component.html', | |
styleUrls: ['./display.component.css'], | |
changeDetection: ChangeDetectionStrategy.OnPush | |
}) | |
export class DisplayComponent { | |
constructor(private changeDetectorRef: ChangeDetectorRef) { | |
} | |
@Input() set dynamicInputUpdateCount(inputData: string) { | |
this._dynamicInputUpdateCount = inputData; | |
this.changeDetectorRef.detectChanges(); | |
} | |
@Input() componentDescription: string; | |
@Input() inputData: string; | |
_dynamicInputUpdateCount: string; | |
@Output() dataUpdated = new EventEmitter<string>(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment