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

basic-devtools-panel-example.component.ts

32 lines1017 Bytes

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