1
- < h3 > Author #{{ author.id }}, with books and photos</ h3 >
1
+ < h3 > Author #{{ author? .id }}, with books and photos</ h3 >
2
2
< demo-resource-info [resource] ="author "> </ demo-resource-info >
3
- <!-- <pre>authors.get('{{ author.id }}', {{ '{' }} include: ['books', 'photos'] {{ '}' }});</pre> -->
3
+ <!-- <pre>authors.get('{{ author? .id }}', {{ '{' }} include: ['books', 'photos'] {{ '}' }});</pre> -->
4
4
< ul >
5
- < li > Name: < strong > {{ author.attributes.name }}</ strong > </ li >
6
- < li > Date of birth: < strong > {{ author.attributes.date_of_birth | date }}</ strong > </ li >
7
- < li > Date of dead: < strong > {{ author.attributes.date_of_death | date }}</ strong > </ li >
5
+ < li > Name: < strong > {{ author? .attributes.name }}</ strong > </ li >
6
+ < li > Date of birth: < strong > {{ author? .attributes.date_of_birth | date }}</ strong > </ li >
7
+ < li > Date of dead: < strong > {{ author? .attributes.date_of_death | date }}</ strong > </ li >
8
8
</ ul >
9
9
< p >
10
10
< button (click) ="newAuthor() "> New author</ button >
@@ -13,35 +13,41 @@ <h3>Author #{{ author.id }}, with books and photos</h3>
13
13
</ p >
14
14
15
15
< h4 > Photos</ h4 >
16
- < demo-collection-info [collection] ="author.relationships.photos "> </ demo-collection-info >
17
- < span *ngIf ="author.relationships.photos.data.length === 0 ">
18
- This author don't have any photo :(
19
- </ span >
20
- < span *ngIf ="author.relationships.photos.builded ">
21
- < img *ngFor ="let photo of author.relationships.photos.data "
22
- [src] ="photo.attributes.uri " height ="150 " style ="padding-right: 1em "
23
- title ="Book id #{{ photo.id }} "
24
- />
25
- </ span >
16
+ < demo-collection-info [collection] ="author?.relationships.photos "> </ demo-collection-info >
17
+ @if (author?.relationships.photos.data.length === 0) {
18
+ < span > This author don't have any photo :(</ span >
19
+ }
20
+ @if (author?.relationships.photos.builded) {
21
+ < span >
22
+ < img *ngFor ="let photo of author()?.relationships.photos.data "
23
+ [src] ="photo.attributes.uri " height ="150 " style ="padding-right: 1em "
24
+ title ="Book id #{{ photo.id }} "
25
+ />
26
+ </ span >
27
+ }
26
28
27
29
< h4 > Books</ h4 >
28
- < demo-collection-info [collection] ="author.relationships.books "> </ demo-collection-info >
29
- < table class ="table table-striped " *ngIf ="author.relationships.books.builded ">
30
- < thead >
31
- < tr >
32
- < th > ID</ th >
33
- < th > Title</ th >
34
- < th > Date Published</ th >
35
- </ tr >
36
- </ thead >
37
- < tr *ngFor ="let book of author.relationships.books.data ">
38
- < td > {{ book.id }}</ td >
39
- < td >
40
- < a [routerLink] ="['/books', book.id] "> {{ book.attributes.title }}</ a >
41
- </ td >
42
- < td > {{ book.attributes.date_published | date }}</ td >
43
- </ tr >
44
- </ table >
30
+ < demo-collection-info [collection] ="author?.relationships.books "> </ demo-collection-info >
31
+ @defer {
32
+ < table class ="table table-striped " *ngIf ="author?.relationships.books.builded ">
33
+ < thead >
34
+ < tr >
35
+ < th > ID</ th >
36
+ < th > Title</ th >
37
+ < th > Date Published</ th >
38
+ </ tr >
39
+ </ thead >
40
+ < ng-container *ngFor ="let book of author?.relationships.books.data; trackBy: trackBookId ">
41
+ < tr >
42
+ < td > {{ book.id }}</ td >
43
+ < td >
44
+ < a [routerLink] ="['/books', book.id] "> {{ book.attributes.title }}</ a >
45
+ </ td >
46
+ < td > {{ book.attributes.date_published | date }}</ td >
47
+ </ tr >
48
+ </ ng-container >
49
+ </ table >
50
+ }
45
51
46
52
< p >
47
53
< a routerLink ="/authors "> Volver</ a >
0 commit comments