You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, the CLI will always generate in the `app` folder. You can tell it to generate in another folder by passing the path before the name of the element you want it to generate. For instance `ng generate component components/dashobard` will generate the `DashboardComponent` 4 files in `app/components/dashboard`. The `components` folder is created by the CLI if it doesn't already exist, as well as the `dashboard` folder.
229
+
By default, the CLI will always generate in the `app` folder. You can tell it to generate in another folder by passing the path before the name of the element you want it to generate. For instance `ng generate component components/dashboard` will generate the `DashboardComponent` 4 files in `app/components/dashboard`. The `components` folder is created by the CLI if it doesn't already exist, as well as the `dashboard` folder.
230
230
:::
231
231
232
232
As the complexity of the folder structure of the application increases, it is a good practice to add aliases in the `tsconfig.json` file. Let's do it now to avoid a tedious refactoring later:
Copy file name to clipboardExpand all lines: docs/src/fr/html/README.md
+7-6Lines changed: 7 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -204,10 +204,11 @@ La directive `ngModel` vous permet de lier la valeur d'un champ de formulaire à
204
204
205
205
```ts
206
206
import { Component } from'@angular/core'
207
+
import { FormsModule } from'@angular/forms'
207
208
208
209
@Component({
209
210
selector: 'app-root',
210
-
imports: [],
211
+
imports: [FormsModule],
211
212
templateUrl: './app.component.html',
212
213
styleUrl: './app.component.scss'
213
214
})
@@ -379,17 +380,17 @@ Un bloc optionnel `@empty` peut être inclus juste après le bloc `@for`. Le con
379
380
À l'intérieur du bloc `@for`, plusieurs variables contextuelles implicites sont toujours disponibles : `$count`, `$index`, `$first`, `$last`, `$odd` et `$even`. Elles peuvent être renommées via un segment `let`, ce qui peut être utile en cas d'utilisation de boucles `@for` imbriquées où les noms des variables contextuelles pourraient entrer en collision.
380
381
381
382
```html
382
-
@for (item of items) {
383
-
<div>{{$item}}/{{$count}}: {{item.name}}</div>
383
+
@for (item of items; track item.id) {
384
+
<div>{{$index}}/{{$count}}: {{item.name}}</div>
384
385
}
385
386
386
-
<!-- Avec un alian pour $index -->
387
-
@for (item of items; let i = $index) {
387
+
<!-- Avec un alias pour $index -->
388
+
@for (item of items; track item.id; let i = $index) {
388
389
<div>{{i}}: {{item.name}}</div>
389
390
}
390
391
391
392
<!-- Avec un alias pour $even -->
392
-
@for (item of items; let isEven = $even) {
393
+
@for (item of items; track item.id; let isEven = $even) {
393
394
<div>{{item.name}} is {{isEven ? 'even': 'odd'}}</div>
Copy file name to clipboardExpand all lines: docs/src/html/README.md
+7-6Lines changed: 7 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -185,7 +185,7 @@ export class AppComponent {
185
185
186
186
## NgModel directive
187
187
188
-
The ngModel directive allows you to bind the value of a form field to a component class variable. It is a two-way binding: the variable is updated when the content of the field changes (typically by the user) and vice versa. The syntax for two-way data binding is `[()]` (banana the box).
188
+
The ngModel directive allows you to bind the value of a form field to a component class variable. It is a two-way binding: the variable is updated when the content of the field changes (typically by the user) and vice versa. The syntax for two-way data binding is `[()]` (banana in the box).
189
189
190
190
<CodeGroup>
191
191
<CodeGroupItemtitle="app.component.html">
@@ -203,10 +203,11 @@ The ngModel directive allows you to bind the value of a form field to a componen
203
203
204
204
```ts
205
205
import { Component } from'@angular/core'
206
+
import { FormsModule } from'@angular/forms'
206
207
207
208
@Component({
208
209
selector: 'app-root',
209
-
imports: [],
210
+
imports: [FormsModule],
210
211
templateUrl: './app.component.html',
211
212
styleUrl: './app.component.scss'
212
213
})
@@ -377,17 +378,17 @@ An optional `@empty` block can be included right after the `@for` block. The con
377
378
Inside the `@for` block, several implicit contextual variables are always available: `$count`, `$index`, `$first`, `$last`, `$odd` and `$even`. They can be aliased via a `let` segment which can be useful in case of using nested `@for` loops where contextual variable names could collide.
378
379
379
380
```html
380
-
@for (item of items) {
381
-
<div>{{$item}}/{{$count}}: {{item.name}}</div>
381
+
@for (item of items; track item.id) {
382
+
<div>{{$index}}/{{$count}}: {{item.name}}</div>
382
383
}
383
384
384
385
<!-- With an alias for $index -->
385
-
@for (item of items; let i = $index) {
386
+
@for (item of items; track item.id; let i = $index) {
386
387
<div>{{i}}: {{item.name}}</div>
387
388
}
388
389
389
390
<!-- With an alias for $even -->
390
-
@for (item of items; let isEven = $even) {
391
+
@for (item of items; track item.id; let isEven = $even) {
391
392
<div>{{item.name}} is {{isEven ? 'even': 'odd'}}</div>
0 commit comments