--- id: disabling-queries title: Disabling/Pausing Queries ref: docs/framework/react/guides/disabling-queries.md replace: { 'useQuery': 'injectQuery' } --- [//]: # 'Example' ```angular-ts @Component({ selector: 'todos', template: `
@if (todosQuery.data()) { } @else { @if (todosQuery.isError()) { Error: {{ todosQuery.error().message }} } @else if (todosQuery.isLoading()) { Loading... } @else if (!todosQuery.isLoading() && !todosQuery.isError()) { Not ready ... } }
{{ todosQuery.isLoading() ? 'Fetching...' : '' }}
`, }) export class TodosComponent { readonly todosQuery = injectQuery(() => ({ queryKey: ['todos'], queryFn: fetchTodoList, enabled: false, })) } ``` [//]: # 'Example' [//]: # 'Example2' ```angular-ts @Component({ selector: 'todos', template: `
// 🚀 applying the filter will enable and execute the query
`, }) export class TodosComponent { filter = signal('') readonly todosQuery = injectQuery(() => ({ queryKey: ['todos', this.filter()], queryFn: () => fetchTodos(this.filter()), enabled: !!this.filter(), })) } ``` [//]: # 'Example2' [//]: # 'Example3' ```angular-ts import { skipToken, injectQuery } from '@tanstack/angular-query-experimental' @Component({ selector: 'todos', template: `
// 🚀 applying the filter will enable and execute the query
`, }) export class TodosComponent { filter = signal('') readonly todosQuery = injectQuery(() => ({ queryKey: ['todos', this.filter()], queryFn: this.filter() ? () => fetchTodos(this.filter()) : skipToken, })) } ``` [//]: # 'Example3'