`,
standalone: true,
+ changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ListItemComponent {
- @Input() id!: number;
- @Input() name!: string;
- @Input() type!: CardType;
+ private teacherStore = inject(TeacherStore);
+ private studentStore = inject(StudentStore);
- constructor(
- private teacherStore: TeacherStore,
- private studentStore: StudentStore,
- ) {}
+ readonly id = input.required();
+ readonly name = input.required();
+ readonly type = input.required();
delete(id: number) {
- if (this.type === CardType.TEACHER) {
+ const type = this.type();
+ if (type === CardType.TEACHER) {
this.teacherStore.deleteOne(id);
- } else if (this.type === CardType.STUDENT) {
+ } else if (type === CardType.STUDENT) {
this.studentStore.deleteOne(id);
}
}
diff --git a/docs/src/content/docs/challenges/angular/1-projection.md b/docs/src/content/docs/challenges/angular/1-projection.md
index c260b6b..127530f 100644
--- a/docs/src/content/docs/challenges/angular/1-projection.md
+++ b/docs/src/content/docs/challenges/angular/1-projection.md
@@ -41,12 +41,11 @@ While the application works, the developer experience is far from being optimal.
## Constraints
- You must refactor the `CardComponent` and `ListItemComponent`.
-- The `NgFor` directive must be declared and remain inside the `CardComponent`. You might be tempted to move it to the `ParentCardComponent` like `TeacherCardComponent`.
-- `CardComponent` should not contain any `NgIf` or `NgSwitch`.
+- The `@for` must be declared and remain inside the `CardComponent`. You might be tempted to move it to the `ParentCardComponent` like `TeacherCardComponent`.
+- `CardComponent` should not contain any conditions.
- CSS: try to avoid using `::ng-deep`. Find a better way to handle CSS styling.
## Bonus Challenges
-- Try to work with the new built-in control flow syntax for loops and conditionals (documentation [here](https://angular.dev/guide/templates/control-flow))
- Use the signal API to manage your components state (documentation [here](https://angular.dev/guide/signals))
- To reference the template, use a directive instead of magic strings ([What is wrong with magic strings?](https://softwareengineering.stackexchange.com/a/365344))
diff --git a/docs/src/content/docs/fr/challenges/angular/1-projection.md b/docs/src/content/docs/fr/challenges/angular/1-projection.md
index 67d431f..509752c 100644
--- a/docs/src/content/docs/fr/challenges/angular/1-projection.md
+++ b/docs/src/content/docs/fr/challenges/angular/1-projection.md
@@ -37,12 +37,11 @@ Bien que l'application fonctionne, l'expérience développeur est loin d'être o
## Contraintes
- Vous devez refactoriser le `CardComponent` et le `ListItemComponent`.
-- La directive `NgFor` doit être déclarée et rester à l'intérieur du `CardComponent`. Vous pourriez être tenté de la déplacer dans le `ParentCardComponent` comme `TeacherCardComponent`.
-- Le composant `CardComponent` ne doit contenir aucun `NgIf` ni `NgSwitch`.
+- La boucle `@for` doit être déclarée et rester à l'intérieur du `CardComponent`. Vous pourriez être tenté de la déplacer dans le `ParentCardComponent` comme `TeacherCardComponent`.
+- Le composant `CardComponent` ne doit contenir aucune condition.
- CSS: essayez d'éviter d'utiliser `::ng-deep`. Trouvez un meilleur moyen de gérer le style CSS.
## Challenges Bonus
-- Essayez de travailler avec la nouvelle syntaxe de contrôle de flux pour les boucles et les conditions (documentation [ici](https://angular.dev/guide/templates/control-flow))
- Utilisez l'API des signals pour gérer l'état de vos composants (documentation [ici](https://angular.dev/guide/signals))
- Pour référencer le template, utilisez une directive au lieu d'une magic string ([Qu'est-ce qui pose problème avec les magic string ?](https://softwareengineering.stackexchange.com/a/365344))