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

README.md

18 lines1.2 KB

1# TanStack Angular Query Devtools Panel Example (Angular Router)
2​
3Embeds the devtools as a panel inside the page instead of the floating toggle.
4​
5Built with [Angular Router](https://angular.dev/guide/routing).
6​
7## How it works
8​
9- `src/app/services/repos/queries.ts` is an `@Injectable` `ReposQueries` whose `detail()` returns `queryOptions` that fetch the `TanStack/query` repository with `HttpClient` and `lastValueFrom`.
10- `src/app/components/example-query.component.ts` reads it with `injectQuery(() => this.#reposQueries.detail())` and is rendered on both routes.
11- `src/app/components/basic-devtools-panel-example.component.ts` calls `injectDevtoolsPanel` with the `<div>` from `viewChild` as `hostElement`, so the panel mounts in that `<div>` while it is open.
12- `src/app/components/lazy-load-devtools-panel-example.component.ts` imports `@tanstack/angular-query-devtools/devtools-panel` in an `effect` only the first time the panel is opened, then calls `injectDevtoolsPanel` with the component's `Injector`.
13- `src/app/app.routes.ts` lazy loads the two examples at `basic` and `lazy` with `loadComponent`, and `src/app/app.config.ts` registers `provideTanStackQuery` without `withDevtools()`.
14​
15To run this example:
16​
17- `npm install`
18- `npm start`