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

basic-devtools-panel-example.component.ts

33 lines1.0 KB

1import { ChangeDetectionStrategy, Component, viewChild } from '@angular/core'
2import { injectDevtoolsPanel } from '@tanstack/angular-query-devtools-experimental'
3import { ExampleQueryComponent } from './example-query.component'
4import type { ElementRef } from '@angular/core'
5​
6@Component({
7 standalone: true,
8 selector: 'basic-devtools-panel-example',
9 changeDetection: ChangeDetectionStrategy.OnPush,
10 template: `
11 <example-query />
12 <h1>Basic devtools panel example</h1>
13 <p>
14 In this example, the devtools panel is loaded programmatically when the
15 button is clicked
16 </p>
17 <button type="button" (click)="isOpen = !isOpen">
18 {{ isOpen ? 'Close' : 'Open' }} the devtools panel
19 </button>
20 @if (isOpen) {
21 <div #div style="height: 500px"></div>
22 }
23 `,
24 imports: [ExampleQueryComponent],
25})
26export default class BasicDevtoolsPanelExampleComponent {
27 isOpen = false
28 divEl = viewChild<ElementRef>('div')
29​
30 devtools = injectDevtoolsPanel(() => ({
31 hostElement: this.divEl(),
32 }))