@anglr/select 17.2.0 → 18.0.0-beta.20260805050455

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/.claude/skills/angular-developer/SKILL.md +130 -130
  2. package/.claude/skills/angular-developer/references/angular-animations.md +160 -160
  3. package/.claude/skills/angular-developer/references/angular-aria.md +410 -410
  4. package/.claude/skills/angular-developer/references/cli.md +86 -86
  5. package/.claude/skills/angular-developer/references/component-harnesses.md +59 -59
  6. package/.claude/skills/angular-developer/references/component-styling.md +91 -91
  7. package/.claude/skills/angular-developer/references/components.md +117 -117
  8. package/.claude/skills/angular-developer/references/creating-services.md +97 -97
  9. package/.claude/skills/angular-developer/references/data-resolvers.md +69 -69
  10. package/.claude/skills/angular-developer/references/define-routes.md +67 -67
  11. package/.claude/skills/angular-developer/references/defining-providers.md +72 -72
  12. package/.claude/skills/angular-developer/references/di-fundamentals.md +120 -120
  13. package/.claude/skills/angular-developer/references/e2e-testing.md +66 -66
  14. package/.claude/skills/angular-developer/references/effects.md +83 -83
  15. package/.claude/skills/angular-developer/references/hierarchical-injectors.md +43 -43
  16. package/.claude/skills/angular-developer/references/host-elements.md +80 -80
  17. package/.claude/skills/angular-developer/references/injection-context.md +63 -63
  18. package/.claude/skills/angular-developer/references/inputs.md +101 -101
  19. package/.claude/skills/angular-developer/references/linked-signal.md +59 -59
  20. package/.claude/skills/angular-developer/references/loading-strategies.md +61 -61
  21. package/.claude/skills/angular-developer/references/mcp.md +106 -106
  22. package/.claude/skills/angular-developer/references/migrations.md +30 -30
  23. package/.claude/skills/angular-developer/references/navigate-to-routes.md +69 -69
  24. package/.claude/skills/angular-developer/references/outputs.md +86 -86
  25. package/.claude/skills/angular-developer/references/reactive-forms.md +122 -122
  26. package/.claude/skills/angular-developer/references/rendering-strategies.md +44 -44
  27. package/.claude/skills/angular-developer/references/resource.md +77 -77
  28. package/.claude/skills/angular-developer/references/route-animations.md +56 -56
  29. package/.claude/skills/angular-developer/references/route-guards.md +52 -52
  30. package/.claude/skills/angular-developer/references/router-lifecycle.md +45 -45
  31. package/.claude/skills/angular-developer/references/router-testing.md +87 -87
  32. package/.claude/skills/angular-developer/references/show-routes-with-outlets.md +68 -68
  33. package/.claude/skills/angular-developer/references/signal-forms.md +897 -897
  34. package/.claude/skills/angular-developer/references/signals-overview.md +94 -94
  35. package/.claude/skills/angular-developer/references/tailwind-css.md +69 -69
  36. package/.claude/skills/angular-developer/references/template-driven-forms.md +114 -114
  37. package/.claude/skills/angular-developer/references/testing-fundamentals.md +66 -66
  38. package/.github/instructions/typescript/code-conventions.md +7 -7
  39. package/.github/instructions/typescript/comments.md +40 -40
  40. package/.github/instructions/typescript/formatting.md +41 -41
  41. package/.github/instructions/typescript/naming-conventions.md +6 -6
  42. package/es2022/extensions/src/extensions/getSearch.js.map +1 -1
  43. package/es2022/extensions/src/extensions/getSelectedOption.js.map +1 -1
  44. package/es2022/extensions/src/extensions/getSelectedOptions.js.map +1 -1
  45. package/es2022/extensions/src/extensions/getValue.js.map +1 -1
  46. package/es2022/extensions/src/extensions/setReadonly.js.map +1 -1
  47. package/es2022/extensions/src/extensions/setValue.js.map +1 -1
  48. package/es2022/extensions/src/index.js.map +1 -1
  49. package/es2022/src/components/index.js.map +1 -1
  50. package/es2022/src/components/option/option.component.js.map +1 -1
  51. package/es2022/src/components/optionGroup/optgroup.component.js.map +1 -1
  52. package/es2022/src/components/select/select.component.js +2 -2
  53. package/es2022/src/components/select/select.component.js.map +1 -1
  54. package/es2022/src/decorators/index.js.map +1 -1
  55. package/es2022/src/decorators/mergeOptionsAsSignal/mergeOptionsAsSignal.decorator.js.map +1 -1
  56. package/es2022/src/directives/highlightInstance/highlightInstance.directive.js.map +1 -1
  57. package/es2022/src/directives/highlightSearch/highlightSearch.directive.js.map +1 -1
  58. package/es2022/src/directives/highlightText/highlightText.directive.js.map +1 -1
  59. package/es2022/src/directives/index.js.map +1 -1
  60. package/es2022/src/directives/normalStateTagTemplate/normalStateTagTemplate.directive.js.map +1 -1
  61. package/es2022/src/directives/normalStateTemplate/normalStateTemplate.directive.js.map +1 -1
  62. package/es2022/src/directives/optionGroupTemplate/optionGroupTemplate.directive.js.map +1 -1
  63. package/es2022/src/directives/optionTemplate/optionTemplate.directive.js.map +1 -1
  64. package/es2022/src/directives/selectAbsolute/selectAbsolute.directive.js.map +1 -1
  65. package/es2022/src/directives/selectControlValueAccessor/selectControlValueAccessor.directive.js.map +1 -1
  66. package/es2022/src/directives/selectEdit/selectEdit.directive.js.map +1 -1
  67. package/es2022/src/directives/selectFormControl/selectFormControl.directive.js.map +1 -1
  68. package/es2022/src/directives/selectMultipleKeepPopup/selectMultipleKeepPopup.directive.js.map +1 -1
  69. package/es2022/src/directives/selectNoCarret/selectNoCarret.directive.js.map +1 -1
  70. package/es2022/src/directives/selectPlaceholder/selectPlaceholder.directive.js.map +1 -1
  71. package/es2022/src/directives/withDirectAccess/withDirectAccess.directive.js.map +1 -1
  72. package/es2022/src/index.js.map +1 -1
  73. package/es2022/src/interfaces/index.js.map +1 -1
  74. package/es2022/src/interfaces/initState/initState.interface.js.map +1 -1
  75. package/es2022/src/interfaces/keyboardAction/keyboardAction.interface.js.map +1 -1
  76. package/es2022/src/interfaces/normalStateContext/normalStateContext.interface.js.map +1 -1
  77. package/es2022/src/interfaces/normalStateTagContext/normalStateTagContext.interface.js.map +1 -1
  78. package/es2022/src/interfaces/optionsGatherer/optionsGatherer.interface.js.map +1 -1
  79. package/es2022/src/interfaces/pluginDescription/pluginDescription.interface.js.map +1 -1
  80. package/es2022/src/interfaces/pluginOptions/pluginOptions.interface.js.map +1 -1
  81. package/es2022/src/interfaces/plugins/index.js.map +1 -1
  82. package/es2022/src/interfaces/plugins/interactions/interactions.interface.js.map +1 -1
  83. package/es2022/src/interfaces/plugins/keyboardHandler/keyboardHandler.interface.js.map +1 -1
  84. package/es2022/src/interfaces/plugins/keyboardHandler/simpleKeyboardHandler.interface.js.map +1 -1
  85. package/es2022/src/interfaces/plugins/liveSearch/editLiveSearch.interface.js.map +1 -1
  86. package/es2022/src/interfaces/plugins/liveSearch/filterLiveSearch.interface.js.map +1 -1
  87. package/es2022/src/interfaces/plugins/liveSearch/liveSearch.interface.js.map +1 -1
  88. package/es2022/src/interfaces/plugins/normalState/editNormalState.interface.js.map +1 -1
  89. package/es2022/src/interfaces/plugins/normalState/normalState.interface.js.map +1 -1
  90. package/es2022/src/interfaces/plugins/normalState/simpleNormalState.interface.js.map +1 -1
  91. package/es2022/src/interfaces/plugins/optionsHandler/optionsHandler.interface.js.map +1 -1
  92. package/es2022/src/interfaces/plugins/optionsHandler/simpleOptionsHandler.interface.js.map +1 -1
  93. package/es2022/src/interfaces/plugins/popup/popup.interface.js.map +1 -1
  94. package/es2022/src/interfaces/plugins/popup/simplePopup.interface.js.map +1 -1
  95. package/es2022/src/interfaces/plugins/positioner/commonPositioner.interface.js.map +1 -1
  96. package/es2022/src/interfaces/plugins/positioner/popoverPositioner.interface.js.map +1 -1
  97. package/es2022/src/interfaces/plugins/positioner/positioner.interface.js.map +1 -1
  98. package/es2022/src/interfaces/plugins/readonlyState/readonlyState.interface.js.map +1 -1
  99. package/es2022/src/interfaces/plugins/valueHandler/dynamicValueHandler.interface.js.map +1 -1
  100. package/es2022/src/interfaces/plugins/valueHandler/valueHandler.interface.js.map +1 -1
  101. package/es2022/src/interfaces/popupContext/popupContext.interface.js.map +1 -1
  102. package/es2022/src/interfaces/selectApi/selectApi.interface.js.map +1 -1
  103. package/es2022/src/interfaces/selectBusOptions/selectBusOptions.interface.js.map +1 -1
  104. package/es2022/src/interfaces/selectCssClasses/selectCssClasses.interface.js.map +1 -1
  105. package/es2022/src/interfaces/selectEvent/selectEvent.interface.js.map +1 -1
  106. package/es2022/src/interfaces/selectEvents/selectEvents.interface.js.map +1 -1
  107. package/es2022/src/interfaces/selectOption/selectOption.interface.js.map +1 -1
  108. package/es2022/src/interfaces/selectOptionGroup/selectOptionGroup.interface.js.map +1 -1
  109. package/es2022/src/interfaces/selectOptionState/selectOptionState.interface.js.map +1 -1
  110. package/es2022/src/interfaces/selectOptionStateSyntetic/selectOptionStateSyntetic.interface.js.map +1 -1
  111. package/es2022/src/interfaces/selectOptions/selectOptions.interface.js.map +1 -1
  112. package/es2022/src/interfaces/selectPlugin/selectPlugin.interface.js.map +1 -1
  113. package/es2022/src/interfaces/selectPluginTypes/selectPluginTypes.interface.js.map +1 -1
  114. package/es2022/src/interfaces/tempValue/tempValue.interface.js.map +1 -1
  115. package/es2022/src/interfaces/templateGatherer/templateGatherer.interface.js.map +1 -1
  116. package/es2022/src/interfaces/visualPluginOptions/visualPluginOptions.interface.js.map +1 -1
  117. package/es2022/src/misc/classes/codeOptionsGatherer/codeOptionsGatherer.interface.js.map +1 -1
  118. package/es2022/src/misc/classes/index.js.map +1 -1
  119. package/es2022/src/misc/classes/selectBus/selectBus.js.map +1 -1
  120. package/es2022/src/misc/classes/selectPluginInstances/selectPluginInstances.js.map +1 -1
  121. package/es2022/src/misc/enums.js.map +1 -1
  122. package/es2022/src/misc/providers.js.map +1 -1
  123. package/es2022/src/misc/tokens.js.map +1 -1
  124. package/es2022/src/misc/types.js.map +1 -1
  125. package/es2022/src/misc/utils.js.map +1 -1
  126. package/es2022/src/modules/index.js.map +1 -1
  127. package/es2022/src/modules/select.module.js.map +1 -1
  128. package/es2022/src/pipes/addNewOption/addNewOption.pipe.js.map +1 -1
  129. package/es2022/src/pipes/displayOptionValue/displayOptionValue.pipe.js.map +1 -1
  130. package/es2022/src/pipes/displayValue/displayValue.pipe.js.map +1 -1
  131. package/es2022/src/pipes/getPlugin/getPlugin.pipe.js.map +1 -1
  132. package/es2022/src/pipes/groupedListOptions/groupedListOptions.pipe.js.map +1 -1
  133. package/es2022/src/pipes/hasValue/hasValue.pipe.js.map +1 -1
  134. package/es2022/src/pipes/index.js.map +1 -1
  135. package/es2022/src/pipes/optionCssClasses/optionCssClasses.pipe.js.map +1 -1
  136. package/es2022/src/plugins/index.js.map +1 -1
  137. package/es2022/src/plugins/interactions/index.js.map +1 -1
  138. package/es2022/src/plugins/interactions/simpleInteractions/simpleInteractions.component.js.map +1 -1
  139. package/es2022/src/plugins/keyboardHandler/index.js.map +1 -1
  140. package/es2022/src/plugins/keyboardHandler/simpleKeyboardHandler/simpleKeyboardHandler.component.js.map +1 -1
  141. package/es2022/src/plugins/liveSearch/editLiveSearch/editLiveSearch.component.js +2 -2
  142. package/es2022/src/plugins/liveSearch/editLiveSearch/editLiveSearch.component.js.map +1 -1
  143. package/es2022/src/plugins/liveSearch/filterLiveSearch/filterLiveSearch.component.js.map +1 -1
  144. package/es2022/src/plugins/liveSearch/index.js.map +1 -1
  145. package/es2022/src/plugins/liveSearch/noLiveSearch/noLiveSearch.component.js.map +1 -1
  146. package/es2022/src/plugins/normalState/editNormalState/editNormalState.component.js +3 -2
  147. package/es2022/src/plugins/normalState/editNormalState/editNormalState.component.js.map +1 -1
  148. package/es2022/src/plugins/normalState/index.js.map +1 -1
  149. package/es2022/src/plugins/normalState/simpleNormalState/simpleNormalState.component.js +5 -6
  150. package/es2022/src/plugins/normalState/simpleNormalState/simpleNormalState.component.js.map +1 -1
  151. package/es2022/src/plugins/optionsHandler/index.js.map +1 -1
  152. package/es2022/src/plugins/optionsHandler/noOptionsHandler/noOptionsHandler.component.js.map +1 -1
  153. package/es2022/src/plugins/optionsHandler/optionsHandlerBase.js.map +1 -1
  154. package/es2022/src/plugins/optionsHandler/simpleOptionsHandler/simpleOptionsHandler.component.js.map +1 -1
  155. package/es2022/src/plugins/popup/index.js.map +1 -1
  156. package/es2022/src/plugins/popup/simplePopup/simplePopup.component.js +2 -2
  157. package/es2022/src/plugins/popup/simplePopup/simplePopup.component.js.map +1 -1
  158. package/es2022/src/plugins/positioner/commonPositioner/commonPositioner.component.js.map +1 -1
  159. package/es2022/src/plugins/positioner/index.js.map +1 -1
  160. package/es2022/src/plugins/positioner/noPositioner/noPositioner.component.js.map +1 -1
  161. package/es2022/src/plugins/positioner/popoverPositioner/popoverPositioner.component.js.map +1 -1
  162. package/es2022/src/plugins/valueHandler/dynamicValueHandler/dynamicValueHandler.component.js.map +1 -1
  163. package/es2022/src/plugins/valueHandler/index.js.map +1 -1
  164. package/es2022/src/plugins/valueHandler/staticValueHandler/staticValueHandler.component.js.map +1 -1
  165. package/package.json +125 -125
  166. package/src/components/select/select.component.css +5 -5
  167. package/src/interfaces/plugins/normalState/editNormalState.interface.d.ts +4 -0
  168. package/src/interfaces/plugins/normalState/editNormalState.interface.d.ts.map +1 -1
  169. package/src/interfaces/plugins/normalState/simpleNormalState.interface.d.ts +1 -5
  170. package/src/interfaces/plugins/normalState/simpleNormalState.interface.d.ts.map +1 -1
  171. package/src/plugins/liveSearch/editLiveSearch/editLiveSearch.component.html +19 -19
  172. package/src/plugins/normalState/editNormalState/editNormalState.component.d.ts.map +1 -1
  173. package/src/plugins/normalState/editNormalState/editNormalState.component.html +52 -50
  174. package/src/plugins/normalState/simpleNormalState/simpleNormalState.component.d.ts.map +1 -1
  175. package/src/plugins/normalState/simpleNormalState/simpleNormalState.component.html +36 -37
  176. package/src/plugins/popup/simplePopup/simplePopup.component.html +56 -56
  177. package/styles/components/_liveSearch.scss +32 -32
  178. package/styles/components/_normalState.scss +121 -116
  179. package/styles/components/_popup.scss +107 -107
  180. package/styles/components/_select.scss +14 -14
  181. package/styles/core/_defaultTheme.scss +105 -105
  182. package/styles/core/_misc.scss +34 -34
  183. package/styles/core/_mixins.scss +29 -29
  184. package/styles/index.scss +2 -2
  185. package/styles/themes/dark.scss +63 -63
  186. package/styles/themes/light.scss +64 -64
  187. package/version.bak +1 -1
@@ -1,117 +1,117 @@
1
- # Components
2
-
3
- Angular components are the fundamental building blocks of an application. Each component consists of a TypeScript class with behaviors, an HTML template, and a CSS selector.
4
-
5
- ## Component Definition
6
-
7
- Use the `@Component` decorator to define a component's metadata.
8
-
9
- ```ts
10
- @Component({
11
- selector: 'app-profile',
12
- template: `
13
- <img src="profile.jpg" alt="Profile photo" />
14
- <button (click)="save()">Save</button>
15
- `,
16
- styles: `
17
- img {
18
- border-radius: 50%;
19
- }
20
- `,
21
- })
22
- export class Profile {
23
- save() {
24
- /* ... */
25
- }
26
- }
27
- ```
28
-
29
- ## Metadata Options
30
-
31
- - `selector`: The CSS selector that identifies this component in templates.
32
- - `template`: Inline HTML template (preferred for small templates).
33
- - `templateUrl`: Path to an external HTML file.
34
- - `styles`: Inline CSS styles.
35
- - `styleUrl` / `styleUrls`: Path(s) to external CSS file(s).
36
- - `imports`: Lists the components, directives, or pipes used in this component's template.
37
-
38
- ## Using Components
39
-
40
- To use a component, add it to the `imports` array of the consuming component and use its selector in the template.
41
-
42
- ```ts
43
- @Component({
44
- selector: 'app-root',
45
- imports: [Profile],
46
- template: `<app-profile />`,
47
- })
48
- export class App {}
49
- ```
50
-
51
- ## Template Control Flow
52
-
53
- Angular uses built-in blocks for conditional rendering and loops.
54
-
55
- ### Conditional Rendering (`@if`)
56
-
57
- Use `@if` to conditionally show content. You can include `@else if` and `@else` blocks.
58
-
59
- ```html
60
- @if (user.isAdmin) {
61
- <admin-dashboard />
62
- } @else if (user.isModerator) {
63
- <mod-dashboard />
64
- } @else {
65
- <standard-dashboard />
66
- }
67
- ```
68
-
69
- **Result aliasing**: Save the result of the expression for reuse.
70
-
71
- ```html
72
- @if (user.settings(); as settings) {
73
- <p>Theme: {{ settings.theme }}</p>
74
- }
75
- ```
76
-
77
- ### Loops (`@for`)
78
-
79
- The `@for` block iterates over collections. The `track` expression is **required** for performance and DOM reuse.
80
-
81
- ```html
82
- <ul>
83
- @for (item of items(); track item.id; let i = $index, total = $count) {
84
- <li>{{ i + 1 }}/{{ total }}: {{ item.name }}</li>
85
- } @empty {
86
- <li>No items to display.</li>
87
- }
88
- </ul>
89
- ```
90
-
91
- **Implicit Variables**: `$index`, `$count`, `$first`, `$last`, `$even`, `$odd`.
92
-
93
- ### Switching Content (`@switch`)
94
-
95
- The `@switch` block renders content based on a value. It uses strict equality (`===`) and has **no fallthrough**.
96
-
97
- ```html
98
- @switch (status()) { @case ('loading') { <app-spinner /> } @case ('error') { <app-error-msg /> }
99
- @case ('success') { <app-data-grid /> } @default {
100
- <p>Unknown status</p>
101
- } }
102
- ```
103
-
104
- **Exhaustive Type Checking**: Use `@default never;` to ensure all cases of a union type are handled.
105
-
106
- ```html
107
- @switch (state) { @case ('on') { ... } @case ('off') { ... } @default never; // Errors if a new
108
- state like 'standby' is added }
109
- ```
110
-
111
- ## Core Concepts
112
-
113
- - **Host Element**: The DOM element that matches the component's selector.
114
- - **View**: The DOM rendered by the component's template inside the host element.
115
- - **Standalone**: By default, components are standalone (since Angular 19, `standalone: true` is default). For older versions, `standalone: true` must be explicit or the component must be part of an `NgModule`.
116
- - **Component Tree**: Angular applications are structured as a tree of components, where each component can host child components.
117
- - **Component Naming**: Do not add suffixes the `Component` suffix for Component classes (e.g., AppComponent) unless the project has been configured to use that naming configuration.
1
+ # Components
2
+
3
+ Angular components are the fundamental building blocks of an application. Each component consists of a TypeScript class with behaviors, an HTML template, and a CSS selector.
4
+
5
+ ## Component Definition
6
+
7
+ Use the `@Component` decorator to define a component's metadata.
8
+
9
+ ```ts
10
+ @Component({
11
+ selector: 'app-profile',
12
+ template: `
13
+ <img src="profile.jpg" alt="Profile photo" />
14
+ <button (click)="save()">Save</button>
15
+ `,
16
+ styles: `
17
+ img {
18
+ border-radius: 50%;
19
+ }
20
+ `,
21
+ })
22
+ export class Profile {
23
+ save() {
24
+ /* ... */
25
+ }
26
+ }
27
+ ```
28
+
29
+ ## Metadata Options
30
+
31
+ - `selector`: The CSS selector that identifies this component in templates.
32
+ - `template`: Inline HTML template (preferred for small templates).
33
+ - `templateUrl`: Path to an external HTML file.
34
+ - `styles`: Inline CSS styles.
35
+ - `styleUrl` / `styleUrls`: Path(s) to external CSS file(s).
36
+ - `imports`: Lists the components, directives, or pipes used in this component's template.
37
+
38
+ ## Using Components
39
+
40
+ To use a component, add it to the `imports` array of the consuming component and use its selector in the template.
41
+
42
+ ```ts
43
+ @Component({
44
+ selector: 'app-root',
45
+ imports: [Profile],
46
+ template: `<app-profile />`,
47
+ })
48
+ export class App {}
49
+ ```
50
+
51
+ ## Template Control Flow
52
+
53
+ Angular uses built-in blocks for conditional rendering and loops.
54
+
55
+ ### Conditional Rendering (`@if`)
56
+
57
+ Use `@if` to conditionally show content. You can include `@else if` and `@else` blocks.
58
+
59
+ ```html
60
+ @if (user.isAdmin) {
61
+ <admin-dashboard />
62
+ } @else if (user.isModerator) {
63
+ <mod-dashboard />
64
+ } @else {
65
+ <standard-dashboard />
66
+ }
67
+ ```
68
+
69
+ **Result aliasing**: Save the result of the expression for reuse.
70
+
71
+ ```html
72
+ @if (user.settings(); as settings) {
73
+ <p>Theme: {{ settings.theme }}</p>
74
+ }
75
+ ```
76
+
77
+ ### Loops (`@for`)
78
+
79
+ The `@for` block iterates over collections. The `track` expression is **required** for performance and DOM reuse.
80
+
81
+ ```html
82
+ <ul>
83
+ @for (item of items(); track item.id; let i = $index, total = $count) {
84
+ <li>{{ i + 1 }}/{{ total }}: {{ item.name }}</li>
85
+ } @empty {
86
+ <li>No items to display.</li>
87
+ }
88
+ </ul>
89
+ ```
90
+
91
+ **Implicit Variables**: `$index`, `$count`, `$first`, `$last`, `$even`, `$odd`.
92
+
93
+ ### Switching Content (`@switch`)
94
+
95
+ The `@switch` block renders content based on a value. It uses strict equality (`===`) and has **no fallthrough**.
96
+
97
+ ```html
98
+ @switch (status()) { @case ('loading') { <app-spinner /> } @case ('error') { <app-error-msg /> }
99
+ @case ('success') { <app-data-grid /> } @default {
100
+ <p>Unknown status</p>
101
+ } }
102
+ ```
103
+
104
+ **Exhaustive Type Checking**: Use `@default never;` to ensure all cases of a union type are handled.
105
+
106
+ ```html
107
+ @switch (state) { @case ('on') { ... } @case ('off') { ... } @default never; // Errors if a new
108
+ state like 'standby' is added }
109
+ ```
110
+
111
+ ## Core Concepts
112
+
113
+ - **Host Element**: The DOM element that matches the component's selector.
114
+ - **View**: The DOM rendered by the component's template inside the host element.
115
+ - **Standalone**: By default, components are standalone (since Angular 19, `standalone: true` is default). For older versions, `standalone: true` must be explicit or the component must be part of an `NgModule`.
116
+ - **Component Tree**: Angular applications are structured as a tree of components, where each component can host child components.
117
+ - **Component Naming**: Do not add suffixes the `Component` suffix for Component classes (e.g., AppComponent) unless the project has been configured to use that naming configuration.
@@ -1,97 +1,97 @@
1
- # Creating and Using Services
2
-
3
- Services in Angular are reusable pieces of code that handle data fetching, business logic, or state management that multiple components or other services need to access.
4
-
5
- ## Creating a Service
6
-
7
- You can generate a service using the Angular CLI:
8
-
9
- ```bash
10
- ng generate service my-data
11
- ```
12
-
13
- Or you can manually create a TypeScript class and decorate it with `@Injectable()`.
14
-
15
- ```ts
16
- import {Injectable} from '@angular/core';
17
-
18
- @Injectable({
19
- providedIn: 'root',
20
- })
21
- export class BasicDataStore {
22
- private data: string[] = [];
23
-
24
- addData(item: string): void {
25
- this.data.push(item);
26
- }
27
-
28
- getData(): string[] {
29
- return [...this.data];
30
- }
31
- }
32
- ```
33
-
34
- ### The `providedIn: 'root'` Option
35
-
36
- Using `providedIn: 'root'` is the recommended approach for most services. It tells Angular to:
37
-
38
- - **Create a single instance (singleton)** for the entire application.
39
- - **Make it available everywhere** automatically, without needing to list it in any `providers` array.
40
- - **Enable tree-shaking**, meaning the service is only included in the final JavaScript bundle if it is actually injected somewhere.
41
-
42
- ## Injecting a Service
43
-
44
- Once a service is created, you can inject it into components, directives, or other services using the `inject()` function.
45
-
46
- ### Injecting into a Component
47
-
48
- ```ts
49
- import {Component, inject} from '@angular/core';
50
- import {BasicDataStore} from './basic-data-store.service';
51
-
52
- @Component({
53
- selector: 'app-example',
54
- template: `
55
- <div>
56
- <p>Data items: {{ dataStore.getData().length }}</p>
57
- <button (click)="dataStore.addData('New Item')">Add Item</button>
58
- </div>
59
- `,
60
- })
61
- export class Example {
62
- // Inject the service as a class field
63
- dataStore = inject(BasicDataStore);
64
- }
65
- ```
66
-
67
- ### Injecting into Another Service
68
-
69
- Services can inject other services in the exact same way.
70
-
71
- ```ts
72
- import {Injectable, inject} from '@angular/core';
73
- import {AdvancedDataStore} from './advanced-data-store.service';
74
-
75
- @Injectable({
76
- providedIn: 'root',
77
- })
78
- export class BasicDataStore {
79
- // Injecting another service
80
- private advancedDataStore = inject(AdvancedDataStore);
81
-
82
- private data: string[] = [];
83
-
84
- getData(): string[] {
85
- // Combine data from this service and the injected service
86
- return [...this.data, ...this.advancedDataStore.getData()];
87
- }
88
- }
89
- ```
90
-
91
- ## Advanced Service Patterns
92
-
93
- While `providedIn: 'root'` covers most scenarios, you may sometimes need:
94
-
95
- - **Component-specific instances**: If a component needs its own isolated instance of a service, provide it directly in the component's `@Component({ providers: [MyService] })` array.
96
- - **Factory providers**: For dynamic creation.
97
- - **Value providers**: For injecting configuration objects.
1
+ # Creating and Using Services
2
+
3
+ Services in Angular are reusable pieces of code that handle data fetching, business logic, or state management that multiple components or other services need to access.
4
+
5
+ ## Creating a Service
6
+
7
+ You can generate a service using the Angular CLI:
8
+
9
+ ```bash
10
+ ng generate service my-data
11
+ ```
12
+
13
+ Or you can manually create a TypeScript class and decorate it with `@Injectable()`.
14
+
15
+ ```ts
16
+ import {Injectable} from '@angular/core';
17
+
18
+ @Injectable({
19
+ providedIn: 'root',
20
+ })
21
+ export class BasicDataStore {
22
+ private data: string[] = [];
23
+
24
+ addData(item: string): void {
25
+ this.data.push(item);
26
+ }
27
+
28
+ getData(): string[] {
29
+ return [...this.data];
30
+ }
31
+ }
32
+ ```
33
+
34
+ ### The `providedIn: 'root'` Option
35
+
36
+ Using `providedIn: 'root'` is the recommended approach for most services. It tells Angular to:
37
+
38
+ - **Create a single instance (singleton)** for the entire application.
39
+ - **Make it available everywhere** automatically, without needing to list it in any `providers` array.
40
+ - **Enable tree-shaking**, meaning the service is only included in the final JavaScript bundle if it is actually injected somewhere.
41
+
42
+ ## Injecting a Service
43
+
44
+ Once a service is created, you can inject it into components, directives, or other services using the `inject()` function.
45
+
46
+ ### Injecting into a Component
47
+
48
+ ```ts
49
+ import {Component, inject} from '@angular/core';
50
+ import {BasicDataStore} from './basic-data-store.service';
51
+
52
+ @Component({
53
+ selector: 'app-example',
54
+ template: `
55
+ <div>
56
+ <p>Data items: {{ dataStore.getData().length }}</p>
57
+ <button (click)="dataStore.addData('New Item')">Add Item</button>
58
+ </div>
59
+ `,
60
+ })
61
+ export class Example {
62
+ // Inject the service as a class field
63
+ dataStore = inject(BasicDataStore);
64
+ }
65
+ ```
66
+
67
+ ### Injecting into Another Service
68
+
69
+ Services can inject other services in the exact same way.
70
+
71
+ ```ts
72
+ import {Injectable, inject} from '@angular/core';
73
+ import {AdvancedDataStore} from './advanced-data-store.service';
74
+
75
+ @Injectable({
76
+ providedIn: 'root',
77
+ })
78
+ export class BasicDataStore {
79
+ // Injecting another service
80
+ private advancedDataStore = inject(AdvancedDataStore);
81
+
82
+ private data: string[] = [];
83
+
84
+ getData(): string[] {
85
+ // Combine data from this service and the injected service
86
+ return [...this.data, ...this.advancedDataStore.getData()];
87
+ }
88
+ }
89
+ ```
90
+
91
+ ## Advanced Service Patterns
92
+
93
+ While `providedIn: 'root'` covers most scenarios, you may sometimes need:
94
+
95
+ - **Component-specific instances**: If a component needs its own isolated instance of a service, provide it directly in the component's `@Component({ providers: [MyService] })` array.
96
+ - **Factory providers**: For dynamic creation.
97
+ - **Value providers**: For injecting configuration objects.
@@ -1,69 +1,69 @@
1
- # Data Resolvers
2
-
3
- Data resolvers fetch data before a route activates, ensuring components have the necessary data upon rendering.
4
-
5
- ## Creating a Resolver
6
-
7
- Implement the `ResolveFn` type.
8
-
9
- ```ts
10
- export const userResolver: ResolveFn<User> = (route, state) => {
11
- const userService = inject(UserService);
12
- const id = route.paramMap.get('id')!;
13
- return userService.getUser(id);
14
- };
15
- ```
16
-
17
- ## Configuring the Route
18
-
19
- Add the resolver under the `resolve` key.
20
-
21
- ```ts
22
- {
23
- path: 'user/:id',
24
- component: UserProfile,
25
- resolve: {
26
- user: userResolver
27
- }
28
- }
29
- ```
30
-
31
- ## Accessing Resolved Data
32
-
33
- ### 1. Via `ActivatedRoute` (Traditional)
34
-
35
- ```ts
36
- private route = inject(ActivatedRoute);
37
- data = toSignal(this.route.data);
38
- user = computed(() => this.data().user);
39
- ```
40
-
41
- ### 2. Via Component Inputs (Modern)
42
-
43
- Enable `withComponentInputBinding()` in `provideRouter` to pass resolved data directly to `@Input` or `input()`.
44
-
45
- ```ts
46
- // app.config.ts
47
- provideRouter(routes, withComponentInputBinding());
48
-
49
- // component.ts
50
- user = input.required<User>();
51
- ```
52
-
53
- ## Error Handling
54
-
55
- Navigation is blocked if a resolver fails.
56
-
57
- - Use `withNavigationErrorHandler` for global handling.
58
- - Use `catchError` within the resolver to return a `RedirectCommand` or fallback data.
59
-
60
- ```ts
61
- return userService
62
- .get(id)
63
- .pipe(catchError(() => of(new RedirectCommand(router.parseUrl('/error')))));
64
- ```
65
-
66
- ## Best Practices
67
-
68
- - **Keep it lightweight**: Fetch only critical data.
69
- - **Provide feedback**: Listen to router events to show a global loading bar during navigation, as the UI stays on the old page until the resolver finishes.
1
+ # Data Resolvers
2
+
3
+ Data resolvers fetch data before a route activates, ensuring components have the necessary data upon rendering.
4
+
5
+ ## Creating a Resolver
6
+
7
+ Implement the `ResolveFn` type.
8
+
9
+ ```ts
10
+ export const userResolver: ResolveFn<User> = (route, state) => {
11
+ const userService = inject(UserService);
12
+ const id = route.paramMap.get('id')!;
13
+ return userService.getUser(id);
14
+ };
15
+ ```
16
+
17
+ ## Configuring the Route
18
+
19
+ Add the resolver under the `resolve` key.
20
+
21
+ ```ts
22
+ {
23
+ path: 'user/:id',
24
+ component: UserProfile,
25
+ resolve: {
26
+ user: userResolver
27
+ }
28
+ }
29
+ ```
30
+
31
+ ## Accessing Resolved Data
32
+
33
+ ### 1. Via `ActivatedRoute` (Traditional)
34
+
35
+ ```ts
36
+ private route = inject(ActivatedRoute);
37
+ data = toSignal(this.route.data);
38
+ user = computed(() => this.data().user);
39
+ ```
40
+
41
+ ### 2. Via Component Inputs (Modern)
42
+
43
+ Enable `withComponentInputBinding()` in `provideRouter` to pass resolved data directly to `@Input` or `input()`.
44
+
45
+ ```ts
46
+ // app.config.ts
47
+ provideRouter(routes, withComponentInputBinding());
48
+
49
+ // component.ts
50
+ user = input.required<User>();
51
+ ```
52
+
53
+ ## Error Handling
54
+
55
+ Navigation is blocked if a resolver fails.
56
+
57
+ - Use `withNavigationErrorHandler` for global handling.
58
+ - Use `catchError` within the resolver to return a `RedirectCommand` or fallback data.
59
+
60
+ ```ts
61
+ return userService
62
+ .get(id)
63
+ .pipe(catchError(() => of(new RedirectCommand(router.parseUrl('/error')))));
64
+ ```
65
+
66
+ ## Best Practices
67
+
68
+ - **Keep it lightweight**: Fetch only critical data.
69
+ - **Provide feedback**: Listen to router events to show a global loading bar during navigation, as the UI stays on the old page until the resolver finishes.