Open History to see the last commit
1---
2id: background-fetching-indicators
3title: Background Fetching Indicators
4ref: docs/framework/react/guides/background-fetching-indicators.md
5---
6β
7[//]: # 'Example'
8β
9```angular-ts
10@Component({
11 selector: 'todos',
12 template: `
13 @if (todosQuery.isPending()) {
14 Loading...
15 } @else if (todosQuery.isError()) {
16 An error has occurred: {{ todosQuery.error().message }}
17 } @else if (todosQuery.isSuccess()) {
18 @if (todosQuery.isFetching()) {
19 Refreshing...
20 }
21 @for (todos of todosQuery.data(); track todo.id) {
22 <todo [todo]="todo" />
23 }
24 }
25 `,
26})
27class TodosComponent {
28 todosQuery = injectQuery(() => ({
29 queryKey: ['todos'],
30 queryFn: fetchTodos,
31 }))
32}
33```
34β
35[//]: # 'Example'
36[//]: # 'Example2'
37β
38```angular-ts
39import { injectIsFetching } from '@tanstack/angular-query-experimental'
40β
41@Component({
42 selector: 'global-loading-indicator',
43 template: `
44 @if (isFetching()) {
45 <div>Queries are fetching in the background...</div>
46 }
47 `,
48})
49export class GlobalLoadingIndicatorComponent {
50 isFetching = injectIsFetching()
51}
52```
53β
54[//]: # 'Example2'