|
|
@@ -24,6 +24,7 @@ export class DankaDetail {
|
|
24
|
24
|
private familyService: FamilyService,
|
|
25
|
25
|
private route: ActivatedRoute,
|
|
26
|
26
|
) {
|
|
|
27
|
+ //遷移先のIDから該当の世帯と家族基本を取得
|
|
27
|
28
|
const id = this.route.snapshot.params['id'];
|
|
28
|
29
|
if (id) {
|
|
29
|
30
|
this.danka = this.dankaService.getDankaById(id);
|
|
|
@@ -32,4 +33,21 @@ export class DankaDetail {
|
|
32
|
33
|
console.log(this.danka);
|
|
33
|
34
|
console.log(this.families);
|
|
34
|
35
|
}
|
|
|
36
|
+
|
|
|
37
|
+ getAge(birthDate: string) {
|
|
|
38
|
+ if (birthDate === '') {
|
|
|
39
|
+ return '-';
|
|
|
40
|
+ }
|
|
|
41
|
+
|
|
|
42
|
+ const birth = new Date(birthDate);
|
|
|
43
|
+ const today: Date = new Date();
|
|
|
44
|
+ const thisYearBirthday = new Date(today.getFullYear(), birth.getMonth(), birth.getDate());
|
|
|
45
|
+
|
|
|
46
|
+ let age = today.getFullYear() - birth.getFullYear();
|
|
|
47
|
+
|
|
|
48
|
+ if (thisYearBirthday > today) {
|
|
|
49
|
+ age--;
|
|
|
50
|
+ }
|
|
|
51
|
+ return age.toString();
|
|
|
52
|
+ }
|
|
35
|
53
|
}
|