Use the following order of groups to organize Angular components:
- Injected dependencies.
- 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. |
Injected dependencies | Services and other dependencies resolved using inject . |
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 /ViewChildren or initialized with contentChild /contentChildren /viewChild /viewChildren . |
I think, that regardless of which table line/block is being sorted in code at the moment
readonly
should be higher. I feel likereadonly
provides an additional level of stricktness and thus should be also takken into account. e.g.:In terms of Angular I would consider
computed
also as areadonly
.