Open History to see the last commit
1import { Component } from '@angular/core'
2import { injectQuery } from '@tanstack/angular-query-experimental'
3β
4@Component({
5 selector: 'app-root',
6 template: `
7 @if (query.isPending()) {
8 <div>Loading...</div>
9 }
10 @if (query.isError()) {
11 <div>An error has occurred!</div>
12 }
13 @if (query.isSuccess()) {
14 <div>{{ query.data() }}</div>
15 }
16 `,
17})
18export class App {
19 query = injectQuery(() => ({
20 queryKey: ['test'],
21 queryFn: async () => {
22 await new Promise((r) => setTimeout(r, 1000))
23 return 'Success'
24 },
25 }))
26}