examples/angular/dynamic-queries
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
TanStack Angular Query Dynamic Queries Example#
A list of items where each item has its own query. Adding or removing an item adds or removes its query.
How it works#
src/app/app.component.tskeeps the items in asignaland maps them to query options insideinjectQueries(() => ({ queries: this.items().map(...) })), so the list of queries follows the signal.- Each query has the key
['item-details', item.id]and aqueryFnthat resolves mock details after a short delay. - The template reads each result by index, for example
queries()[index].isPending()andqueries()[index].data(). src/app/app.config.tsregisters theQueryClientwithprovideTanStackQueryandwithDevtools().
To run this example:
npm installnpm start