Skip to content

Instantly share code, notes, and snippets.

@LayZeeDK
Created March 18, 2021 21:53
Show Gist options
  • Save LayZeeDK/d068ae084699b35dcdf8354d7dd829bc to your computer and use it in GitHub Desktop.
Save LayZeeDK/d068ae084699b35dcdf8354d7dd829bc to your computer and use it in GitHub Desktop.
Ordering of Angular component class members.

Ordering of Angular component class members

Use the following order of groups to organize Angular components:

  1. Private properties.
  2. Data binding properties.
  3. View and content properties.
  4. UI properties.
  5. Component API properties.
  6. Constructor.
  7. Lifecycle hooks.
  8. Event handlers.
  9. Component API methods.
  10. Private methods.
Group Description
Component API methods Public methods intended to be used by other components, directives, or services.
Component API properties Public properties intended to be used by other components, directives, or services.
Data binding properties Properties decorated by Input or Output.
Event handlers. Methods used by the component template.
Lifecycle hooks Methods implementing the AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, DoCheck OnChanges, OnDestroy, or OnInit interfaces.
Private properties Properties marked by private or #.
UI properties Public properties used by the component template.
View and content properties Properties decorated by ContentChild, ContentChildren, ViewChild, or ViewChildren.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment