Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

posts.component.html

34 lines890 Bytes

1<div>
2 <h1>Posts</h1>
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]="
16 queryClient.getQueryData(['post', post.id])
17 ? {
18 fontWeight: 'bold',
19 color: 'green',
20 }
21 : {}
22 "
23 >{{ post.title }}</a
24 >
25 </p>
26 }
27 </div>
28 }
29 <div>
30 @if (postsQuery.isFetching()) {
31 Background Updating...
32 }
33 </div>
34</div>