File tree Expand file tree Collapse file tree 6 files changed +52
-57
lines changed
basic-persister/src/app/components
devtools-panel/src/app/components
infinite-query-with-max-pages/src/app/components
query-options-from-a-service/src/app/components
router/src/app/components Expand file tree Collapse file tree 6 files changed +52
-57
lines changed Original file line number Diff line number Diff line change 1
1
< div >
2
2
< h1 > Posts</ h1 >
3
- @switch (postsQuery.status()) {
4
- @case ('pending') {
5
- Loading...
6
- }
7
- @case ('error') {
8
- Error: {{ postsQuery.error()?.message }}
9
- }
10
- @default {
11
- < div class ="todo-container ">
12
- @for (post of postsQuery.data(); track post.id) {
13
- < p >
14
- <!-- We can access the query data here to show bold links for-->
15
- <!-- ones that are cached-->
16
- < a
17
- href ="# "
18
- (click) ="setPostId.emit(post.id) "
19
- [style] ="
20
- queryClient.getQueryData(['post', post.id])
21
- ? {
22
- fontWeight: 'bold',
23
- color: 'green',
24
- }
25
- : {}
26
- "
27
- > {{ post.title }}</ a
28
- >
29
- </ p >
30
- }
31
- </ div >
32
- }
3
+ @if (postsQuery.isPending()) {
4
+ Loading...
5
+ } @else if (postsQuery.isError()) {
6
+ Error: {{ postsQuery.error().message }}
7
+ } @else if (postsQuery.isSuccess()) {
8
+ < div class ="todo-container ">
9
+ @for (post of postsQuery.data(); track post.id) {
10
+ < p >
11
+ <!-- We can access the query data here to show bold links for-->
12
+ <!-- ones that are cached-->
13
+ < a
14
+ href ="# "
15
+ (click) ="setPostId.emit(post.id) "
16
+ [style] ="
17
+ queryClient.getQueryData(['post', post.id])
18
+ ? {
19
+ fontWeight: 'bold',
20
+ color: 'green',
21
+ }
22
+ : {}
23
+ "
24
+ > {{ post.title }}</ a
25
+ >
26
+ </ p >
27
+ }
28
+ </ div >
33
29
}
34
30
< div >
35
31
@if (postsQuery.isFetching()) {
Original file line number Diff line number Diff line change @@ -22,7 +22,8 @@ interface Response {
22
22
@if (query.isError()) {
23
23
<div>An error has occurred: {{ query.error().message }}</div>
24
24
}
25
- @if (query.data(); as data) {
25
+ @if (query.isSuccess()) {
26
+ @let data = query.data();
26
27
<h1>{{ data.name }}</h1>
27
28
<p>{{ data.description }}</p>
28
29
<strong>👀 {{ data.subscribers_count }}</strong>
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ <h3>3 pages max</h3>
5
5
@if (query.isPending()) {
6
6
< p > Loading...</ p >
7
7
} @else if (query.isError()) {
8
- < span > Error: {{ query.error()? .message }}</ span >
8
+ < span > Error: {{ query.error().message }}</ span >
9
9
} @else {
10
10
< div >
11
11
< button
@@ -15,7 +15,7 @@ <h3>3 pages max</h3>
15
15
{{ previousButtonText() }}
16
16
</ button >
17
17
</ div >
18
- @for (page of query.data()? .pages; track $index) {
18
+ @for (page of query.data().pages; track $index) {
19
19
@for (project of page.data; track project.id) {
20
20
< p [projectStyle] ="project.id "> {{ project.name }} {{ project.id }}</ p >
21
21
}
Original file line number Diff line number Diff line change 7
7
} @else if (postQuery.isError()) {
8
8
Error: {{ postQuery.error().message }}
9
9
}
10
- @if (postQuery.data(); as post) {
10
+ @if (postQuery.isSuccess()) {
11
+ @let post = postQuery.data();
11
12
< h1 > {{ post.title }}</ h1 >
12
13
< div >
13
14
< p > {{ post.body }}</ p >
Original file line number Diff line number Diff line change 1
1
< div >
2
2
< h1 > Posts</ h1 >
3
- @switch (postsQuery.status()) {
4
- @case ('pending') {
5
- Loading...
6
- }
7
- @case ('error') {
8
- Error: {{ postsQuery.error()?.message }}
9
- }
10
- @default {
11
- < div class ="todo-container ">
12
- @for (post of postsQuery.data(); track post.id) {
13
- < p >
14
- <!-- We can access the query data here to show bold links for-->
15
- <!-- ones that are cached-->
16
- < a
17
- routerLink ="post/{{ post.id }} "
18
- [style] ="
3
+ @if (postsQuery.isPending()) {
4
+ Loading...
5
+ } @else if (postsQuery.isError()) {
6
+ Error: {{ postsQuery.error().message }}
7
+ } @else if (postsQuery.isSuccess()) {
8
+ < div class ="todo-container ">
9
+ @for (post of postsQuery.data(); track post.id) {
10
+ < p >
11
+ <!-- We can access the query data here to show bold links for-->
12
+ <!-- ones that are cached-->
13
+ < a
14
+ routerLink ="post/{{ post.id }} "
15
+ [style] ="
19
16
queryClient.getQueryData(['post', post.id])
20
17
? {
21
18
fontWeight: 'bold',
22
19
color: 'green',
23
20
}
24
21
: {}
25
22
"
26
- > {{ post.title }}</ a
27
- >
28
- </ p >
29
- }
30
- </ div >
31
- }
23
+ > {{ post.title }}</ a
24
+ >
25
+ </ p >
26
+ }
27
+ </ div >
32
28
}
33
29
< div >
34
30
@if (postsQuery.isFetching()) {
Original file line number Diff line number Diff line change 7
7
} @else if (postQuery.isError()) {
8
8
Error: {{ postQuery.error().message }}
9
9
}
10
- @if (postQuery.data(); as post) {
10
+ @if (postQuery.isSuccess()) {
11
+ @let post = postQuery.data();
11
12
< h1 > {{ post.title }}</ h1 >
12
13
< div >
13
14
< p > {{ post.body }}</ p >
You can’t perform that action at this time.
0 commit comments