Open History to see the last commit
1import { ChangeDetectionStrategy, Component, inject } from '@angular/core'
2import { injectQuery } from '@tanstack/angular-query-experimental'
3import { ReposQueries } from '../services/repos/queries'
4β
5@Component({
6 changeDetection: ChangeDetectionStrategy.OnPush,
7 selector: 'example-query',
8 template: `
9 <div style="padding-bottom: 20px">
10 @if (query.isPending()) {
11 <div>Loading...</div>
12 }
13 @if (query.isError()) {
14 <div>An error has occurred: {{ query.error().message }}</div>
15 }
16 @if (query.isSuccess()) {
17 @let data = query.data();
18 <h1>{{ data.name }}</h1>
19 <p>{{ data.description }}</p>
20 <strong>π {{ data.subscribers_count }}</strong>
21 <strong>β¨ {{ data.stargazers_count }}</strong>
22 <strong>π΄ {{ data.forks_count }}</strong>
23 }
24 </div>
25 `,
26})
27export class ExampleQueryComponent {
28 readonly #reposQueries = inject(ReposQueries)
29β
30 readonly query = injectQuery(() => this.#reposQueries.detail())
31}