Use the following order of groups to organize Angular components:
- Private properties.
- Data binding properties.
- View and content properties.
- UI properties.
- Component API properties.
- Constructor.
- Lifecycle hooks.
- Event handlers.
- Component API methods.
- 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 /Output or initialized with input /output . |
Event handlers | protected 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 | protected properties used by the component template. |
View and content properties | Properties decorated by ContentChild , ContentChildren , ViewChild , or ViewChildren . |