- @if (type() === CardType.TEACHER) {
-
![]()
- }
- @if (type() === CardType.STUDENT) {
-
![]()
- }
+
+
-
- @for (item of list(); track item) {
-
- }
-
+
+
+
`,
- imports: [ListItemComponent, NgOptimizedImage],
+ imports: [CommonModule],
})
export class CardComponent {
- private teacherStore = inject(TeacherStore);
- private studentStore = inject(StudentStore);
+ @Output() add = new EventEmitter
();
+ @Input() list: any[] | null = null;
- readonly list = input(null);
- readonly type = input.required();
- readonly customClass = input('');
-
- CardType = CardType;
-
- addNewItem() {
- const type = this.type();
- if (type === CardType.TEACHER) {
- this.teacherStore.addOne(randTeacher());
- } else if (type === CardType.STUDENT) {
- this.studentStore.addOne(randStudent());
- }
- }
+ @ContentChild('rowTemplate', { read: TemplateRef })
+ rowTemplate!: TemplateRef;
}
diff --git a/apps/angular/1-projection/src/app/ui/list-item/list-item.component.ts b/apps/angular/1-projection/src/app/ui/list-item/list-item.component.ts
index cffabb451..79a06e495 100644
--- a/apps/angular/1-projection/src/app/ui/list-item/list-item.component.ts
+++ b/apps/angular/1-projection/src/app/ui/list-item/list-item.component.ts
@@ -1,40 +1,31 @@
import {
ChangeDetectionStrategy,
Component,
- inject,
- input,
+ EventEmitter,
+ Output,
} from '@angular/core';
-import { StudentStore } from '../../data-access/student.store';
-import { TeacherStore } from '../../data-access/teacher.store';
-import { CardType } from '../../model/card.model';
@Component({
selector: 'app-list-item',
template: `
-
- {{ name() }}
-