瀏覽代碼

[add]

家族情報編集serviceの削除処理を追加
poohr 3 週之前
父節點
當前提交
ca56dd1ede
共有 1 個文件被更改,包括 12 次插入5 次删除
  1. 12
    5
      src/app/services/family-service.ts

+ 12
- 5
src/app/services/family-service.ts 查看文件

@@ -36,19 +36,26 @@ export class FamilyService {
36 36
     return this.families.filter((family) => family.dankaId === dankaId);
37 37
   }
38 38
 
39
-  //家族個人の情報を取得
39
+  //家族の情報を取得
40 40
   getFamilyById(id: string): Family | undefined {
41 41
     return this.families.find((family) => family.id === id);
42 42
   }
43 43
 
44
+  //家族の情報を更新
44 45
   saveFamily(updateFamily: Family) {
45 46
     const index = this.families.findIndex((families) => families.id === updateFamily.id);
46 47
     if (index === -1) {
47
-     this.families.push(updateFamily);
48
-     return;
48
+      this.families.push(updateFamily);
49
+      return;
49 50
     }
50 51
     this.families[index] = updateFamily;
51 52
   }
52
-  // updateFamily(family: Family);
53
-  // deleteFamily(id: string);
53
+  //家族の情報を削除
54
+  deleteFamily(id: string | undefined) {
55
+    const index = this.families.findIndex((family) => family.id === id);
56
+    if (index === -1) {
57
+      return;
58
+    }
59
+    this.families.splice(index, 1);
60
+  }
54 61
 }

Loading…
取消
儲存