Skip to content

Instantly share code, notes, and snippets.

@dpsthree
Created September 21, 2017 03:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpsthree/3c9ebff2640c7d61a3e930b5d18411d8 to your computer and use it in GitHub Desktop.
Save dpsthree/3c9ebff2640c7d61a3e930b5d18411d8 to your computer and use it in GitHub Desktop.
Simplest OnPush Example
<!--
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>
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