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

README.md

15 lines765 Bytes

1# TanStack Angular Query Dynamic Queries Example
2​
3A list of items where each item has its own query. Adding or removing an item adds or removes its query.
4​
5## How it works
6​
7- `src/app/app.component.ts` keeps the items in a `signal` and maps them to query options inside `injectQueries(() => ({ queries: this.items().map(...) }))`, so the list of queries follows the signal.
8- Each query has the key `['item-details', item.id]` and a `queryFn` that resolves mock details after a short delay.
9- The template reads each result by index, for example `queries()[index].isPending()` and `queries()[index].data()`.
10- `src/app/app.config.ts` registers the `QueryClient` with `provideTanStackQuery` and `withDevtools()`.
11​
12To run this example:
13​
14- `npm install`
15- `npm start`