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