@@ -12,14 +12,12 @@ import {
1212import { StudentStore } from '../../data-access/student.store' ;
1313import { CardType } from '../../model/card.model' ;
1414import { CardComponent } from '../../ui/card/card.component' ;
15+ import { ListItemComponent } from '../../ui/list-item/list-item.component' ;
1516
1617@Component ( {
1718 selector : 'app-student-card' ,
1819 template : `
19- <app-card
20- [list]="students()"
21- [type]="cardType"
22- customClass="bg-light-green">
20+ <app-card [list]="students()" customClass="bg-light-green">
2321 <div card-header class="flex flex-col items-center">
2422 <img
2523 ngSrc="assets/img/student.webp"
@@ -29,6 +27,14 @@ import { CardComponent } from '../../ui/card/card.component';
2927 priority />
3028 </div>
3129
30+ <ng-template #itemTemplate let-item>
31+ <app-list-item
32+ [name]="item.firstName"
33+ [id]="item.id"
34+ [type]="cardType"
35+ (emitDelete)="deleteSingle($event)" />
36+ </ng-template>
37+
3238 <div card-action>
3339 <button
3440 class="rounded-sm border border-blue-500 bg-blue-300 p-2"
@@ -40,12 +46,12 @@ import { CardComponent } from '../../ui/card/card.component';
4046 ` ,
4147 styles : [
4248 `
43- ::ng-deep .bg-light-green {
44- background-color : rgba(0, 250, 0, 0.1);
49+ :host {
50+ --card-bg : rgba(0, 250, 0, 0.1);
4551 }
4652 ` ,
4753 ] ,
48- imports : [ CardComponent , NgOptimizedImage ] ,
54+ imports : [ CardComponent , NgOptimizedImage , ListItemComponent ] ,
4955 changeDetection : ChangeDetectionStrategy . OnPush ,
5056} )
5157export class StudentCardComponent implements OnInit {
@@ -64,4 +70,8 @@ export class StudentCardComponent implements OnInit {
6470 addNew ( ) : void {
6571 this . studentStore . addOne ( randStudent ( ) ) ;
6672 }
73+
74+ deleteSingle ( id : number ) : void {
75+ this . studentStore . deleteOne ( id ) ;
76+ }
6777}
0 commit comments