diff --git a/apps/angular/1-projection/src/app/component/city-card/city-card.component.ts b/apps/angular/1-projection/src/app/component/city-card/city-card.component.ts
index 30c8f88ec..125eac4a0 100644
--- a/apps/angular/1-projection/src/app/component/city-card/city-card.component.ts
+++ b/apps/angular/1-projection/src/app/component/city-card/city-card.component.ts
@@ -1,13 +1,57 @@
import { Component, OnInit } from '@angular/core';
+import { FakeHttpService, randomCity, randTeacher } from '../../data-access/fake-http.service';
+import { CardComponent } from '../../ui/card/card.component';
+import { City } from '../../model/city.model';
+import { CityStore } from '../../data-access/city.store';
+import { ListItemComponent } from '../../ui/list-item/list-item.component';
@Component({
selector: 'app-city-card',
- template: 'TODO City',
+ template: `
+
+
+
+
+
+
+
+
+ `,
+ styles: [
+ `
+ ::ng-deep .bg-light-orange {
+ background-color: orange;
+ }
+ `,
+ ],
standalone: true,
- imports: [],
+ imports: [CardComponent, ListItemComponent],
})
export class CityCardComponent implements OnInit {
- constructor() {}
+ cities: City[] = [];
+
+ constructor(
+ private http: FakeHttpService,
+ private store: CityStore,
+ ) {}
+
+ ngOnInit(): void {
+ this.http.fetchCities$.subscribe((t) => this.store.addAll(t));
+
+ this.store.cities$.subscribe((t) => (this.cities = t));
+ }
+ onAddItem(){
+ this.store.addOne(randomCity());
+ }
- ngOnInit(): void {}
+ onDeleteItem(id: number){
+ this.store.deleteOne(id);
+ }
}
diff --git a/apps/angular/1-projection/src/app/component/student-card/student-card.component.ts b/apps/angular/1-projection/src/app/component/student-card/student-card.component.ts
index 441cda189..28fa58ad1 100644
--- a/apps/angular/1-projection/src/app/component/student-card/student-card.component.ts
+++ b/apps/angular/1-projection/src/app/component/student-card/student-card.component.ts
@@ -1,17 +1,28 @@
import { Component, OnInit } from '@angular/core';
-import { FakeHttpService } from '../../data-access/fake-http.service';
+import { FakeHttpService, randStudent } from '../../data-access/fake-http.service';
import { StudentStore } from '../../data-access/student.store';
-import { CardType } from '../../model/card.model';
import { Student } from '../../model/student.model';
import { CardComponent } from '../../ui/card/card.component';
+import { ListItemComponent } from '../../ui/list-item/list-item.component';
@Component({
selector: 'app-student-card',
template: `
+ (addItem)="onAddItem()"
+ customClass="bg-light-green">
+
+
+
+
+
+
+
`,
standalone: true,
styles: [
@@ -21,11 +32,10 @@ import { CardComponent } from '../../ui/card/card.component';
}
`,
],
- imports: [CardComponent],
+ imports: [CardComponent, ListItemComponent],
})
export class StudentCardComponent implements OnInit {
students: Student[] = [];
- cardType = CardType.STUDENT;
constructor(
private http: FakeHttpService,
@@ -37,4 +47,12 @@ export class StudentCardComponent implements OnInit {
this.store.students$.subscribe((s) => (this.students = s));
}
+
+ onAddItem(){
+ this.store.addOne(randStudent());
+ }
+
+ onDeleteItem(id: number){
+ this.store.deleteOne(id);
+ }
}
diff --git a/apps/angular/1-projection/src/app/component/teacher-card/teacher-card.component.ts b/apps/angular/1-projection/src/app/component/teacher-card/teacher-card.component.ts
index 995cb7c2f..eaabd6a60 100644
--- a/apps/angular/1-projection/src/app/component/teacher-card/teacher-card.component.ts
+++ b/apps/angular/1-projection/src/app/component/teacher-card/teacher-card.component.ts
@@ -1,17 +1,29 @@
import { Component, OnInit } from '@angular/core';
-import { FakeHttpService } from '../../data-access/fake-http.service';
+import { FakeHttpService, randTeacher } from '../../data-access/fake-http.service';
import { TeacherStore } from '../../data-access/teacher.store';
-import { CardType } from '../../model/card.model';
import { Teacher } from '../../model/teacher.model';
import { CardComponent } from '../../ui/card/card.component';
+import { ListItemComponent } from '../../ui/list-item/list-item.component';
@Component({
selector: 'app-teacher-card',
template: `
+ (addItem)="onAddItem()"
+ customClass="bg-light-red">
+
+
+
+
+
+
+
+
`,
styles: [
`
@@ -21,11 +33,10 @@ import { CardComponent } from '../../ui/card/card.component';
`,
],
standalone: true,
- imports: [CardComponent],
+ imports: [CardComponent, ListItemComponent],
})
export class TeacherCardComponent implements OnInit {
teachers: Teacher[] = [];
- cardType = CardType.TEACHER;
constructor(
private http: FakeHttpService,
@@ -37,4 +48,11 @@ export class TeacherCardComponent implements OnInit {
this.store.teachers$.subscribe((t) => (this.teachers = t));
}
+ onAddItem(){
+ this.store.addOne(randTeacher());
+ }
+
+ onDeleteItem(id: number){
+ this.store.deleteOne(id);
+ }
}
diff --git a/apps/angular/1-projection/src/app/ui/card/card.component.ts b/apps/angular/1-projection/src/app/ui/card/card.component.ts
index f06c9ae00..8543a3438 100644
--- a/apps/angular/1-projection/src/app/ui/card/card.component.ts
+++ b/apps/angular/1-projection/src/app/ui/card/card.component.ts
@@ -1,10 +1,5 @@
-import { NgFor, NgIf } from '@angular/common';
-import { Component, Input } from '@angular/core';
-import { randStudent, randTeacher } from '../../data-access/fake-http.service';
-import { StudentStore } from '../../data-access/student.store';
-import { TeacherStore } from '../../data-access/teacher.store';
-import { CardType } from '../../model/card.model';
-import { ListItemComponent } from '../list-item/list-item.component';
+import { CommonModule, NgFor, NgIf } from '@angular/common';
+import { Component, Input, Output, EventEmitter, ViewChild, TemplateRef, ContentChild } from '@angular/core';
@Component({
selector: 'app-card',
@@ -12,22 +7,16 @@ import { ListItemComponent } from '../list-item/list-item.component';
-

-

-
+
+
+
+
+
+