Skip to content

Commit f0741db

Browse files
committed
docs(angular-query): fix nullish coalescing warnings in examples
1 parent f7cf1b5 commit f0741db

File tree

6 files changed

+52
-57
lines changed

6 files changed

+52
-57
lines changed

examples/angular/basic-persister/src/app/components/posts.component.html

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,31 @@
11
<div>
22
<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>
3329
}
3430
<div>
3531
@if (postsQuery.isFetching()) {

examples/angular/devtools-panel/src/app/components/example-query.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ interface Response {
2222
@if (query.isError()) {
2323
<div>An error has occurred: {{ query.error().message }}</div>
2424
}
25-
@if (query.data(); as data) {
25+
@if (query.isSuccess()) {
26+
@let data = query.data();
2627
<h1>{{ data.name }}</h1>
2728
<p>{{ data.description }}</p>
2829
<strong>👀 {{ data.subscribers_count }}</strong>

examples/angular/infinite-query-with-max-pages/src/app/components/example.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ <h3>3 pages max</h3>
55
@if (query.isPending()) {
66
<p>Loading...</p>
77
} @else if (query.isError()) {
8-
<span>Error: {{ query.error()?.message }}</span>
8+
<span>Error: {{ query.error().message }}</span>
99
} @else {
1010
<div>
1111
<button
@@ -15,7 +15,7 @@ <h3>3 pages max</h3>
1515
{{ previousButtonText() }}
1616
</button>
1717
</div>
18-
@for (page of query.data()?.pages; track $index) {
18+
@for (page of query.data().pages; track $index) {
1919
@for (project of page.data; track project.id) {
2020
<p [projectStyle]="project.id">{{ project.name }} {{ project.id }}</p>
2121
}

examples/angular/query-options-from-a-service/src/app/components/post.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
} @else if (postQuery.isError()) {
88
Error: {{ postQuery.error().message }}
99
}
10-
@if (postQuery.data(); as post) {
10+
@if (postQuery.isSuccess()) {
11+
@let post = postQuery.data();
1112
<h1>{{ post.title }}</h1>
1213
<div>
1314
<p>{{ post.body }}</p>

examples/angular/query-options-from-a-service/src/app/components/posts.component.html

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
11
<div>
22
<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]="
1916
queryClient.getQueryData(['post', post.id])
2017
? {
2118
fontWeight: 'bold',
2219
color: 'green',
2320
}
2421
: {}
2522
"
26-
>{{ post.title }}</a
27-
>
28-
</p>
29-
}
30-
</div>
31-
}
23+
>{{ post.title }}</a
24+
>
25+
</p>
26+
}
27+
</div>
3228
}
3329
<div>
3430
@if (postsQuery.isFetching()) {

examples/angular/router/src/app/components/post.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
} @else if (postQuery.isError()) {
88
Error: {{ postQuery.error().message }}
99
}
10-
@if (postQuery.data(); as post) {
10+
@if (postQuery.isSuccess()) {
11+
@let post = postQuery.data();
1112
<h1>{{ post.title }}</h1>
1213
<div>
1314
<p>{{ post.body }}</p>

0 commit comments

Comments
 (0)