Skip to content

Commit 1202283

Browse files
dpaloujleyva
authored andcommitted
[docs] app: Document new policy for constants used in templates
1 parent e698b01 commit 1202283

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

general/development/policies/codingstyle-moodleapp.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,33 @@ export class MyService {
431431

432432
</InvalidExample>
433433

434+
If a constant needs to be used in a component template, it should be declared in the component without "static" because static properties cannot be used in templates. Please notice that the naming convention for non static properties is camelCase.
435+
436+
<ValidExample title="Good">
437+
438+
```ts
439+
export class MyComponent {
440+
441+
protected readonly myConstant = '...';
442+
443+
}
444+
```
445+
446+
</ValidExample>
447+
448+
<InvalidExample title="Bad">
449+
450+
```ts
451+
452+
export class MyService {
453+
454+
protected readonly MY_CONSTANT = '...';
455+
456+
}
457+
```
458+
459+
</InvalidExample>
460+
434461
## Angular
435462

436463
### Avoid calling methods in templates

0 commit comments

Comments
 (0)