Created
September 21, 2017 03:15
-
-
Save dpsthree/3c9ebff2640c7d61a3e930b5d18411d8 to your computer and use it in GitHub Desktop.
Simplest OnPush Example
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
<!-- | |
Since all bound values arrive as inputs | |
this component is suitable for use with OnPush | |
--> | |
<ul> | |
<li *ngFor="let instructor of instructors"> | |
{{ instructor }} | |
</li> | |
</ul> |
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, Input, ChangeDetectionStrategy} from '@angular/core'; | |
// Though this is a simple component, its template will only be checked for updates | |
// should a new list of instructors arrive. | |
// This is especially helpful when other portions of the application are undergoing | |
// frequent updates. | |
@Component({ | |
selector: 'app-instructor-list', | |
templateUrl: './instructor-list.component.html', | |
changeDetection: ChangeDetectionStrategy.OnPush | |
}) | |
export class InstructorListComponent { | |
@Input() instructors = []; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment