This document is the extension of the original Angular Styleguide and overrides some original rules. Must be applied in common.
- Imports must be at the beginning of a source file and must keep the following order:
- Angular libraries
- Angular-related vendor libraries
- Other vendor libraries
- Custom libraries
- Custom modules
- Custom services
- Custom components and directives
- Custom models
- Component properties must keep the following order:
- Decorated properties
- Private properties
- Protected properties
- Public properties
- Constructor method
- Private methods
- Protected methods
- Public methods:
- Angular lifecycle hooks
- Ionic lifecycle hooks
- Static methods
- All the component properies must be declared and typed in the class body.
- All the component properties must be initialized in the constructor method.
-
Every custom component/directive must be prefixed:
ion-content,mot-button,blog-cardetc. -
Every html element must be placed at newline if possible/correct
-
Every html element that has elements of the Angular Template syntax should have it's elements sorted in the following order:
- Structural directives
- Template variable declaration
- Two-way data bindings
- One-way data bindings
0. Standart/built-in Angular directives and its input properties
- 3rd-party directives and its input properties
- Custom directives and its input properties
- Styling directives(NgStyle, NgClass)
- Standart/built-in DOM properties
- Standart/built-in DOM attributes
- Event handlers
- Attributes with assignment
- Attributes without assignment
E.g.
<form
#formHost
[formGroup]="loginForm"
[ngxGroup]="formHost"
[blogForm]="loginForm.controls"
[ngClass]="formClasses"
[id]="loginFormId"
[attr.data-pending]="formHost.pending"
(ngSubmit)="handleSubmit($event)"
class="form"
novalidate>
<!--
#formHost - Template variable declaration
[formGroup]="loginForm" - Standart/built-in Angular directives and its input properties
[ngxGroup]="formHost" - 3rd-party directives and its input properties
[blogForm]="loginForm" - Custom directives and its input properties
[ngClass]="formClasses" - Styling directives(NgStyle, NgClass)
[id]="loginFormId" - Standart/built-in DOM properties
[attr.data-pending]="formHost.pending" - Standart/built-in DOM attributes
(ngSubmit)="handleSubmit($event)" - Event handlers
class="form" - Attributes with assignment
novalidate - Attributes without assignment
-->
</form>