snapshot of https://github.com/TanStack/query.git (main, 2026-09-16; blobs > 131072B omitted)
This commit is contained in:
10
examples/angular/simple/src/app/app.component.ts
Normal file
10
examples/angular/simple/src/app/app.component.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { ChangeDetectionStrategy, Component } from '@angular/core'
|
||||
import { SimpleExampleComponent } from './components/simple-example.component'
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
imports: [SimpleExampleComponent],
|
||||
template: `<simple-example />`,
|
||||
})
|
||||
export class AppComponent {}
|
||||
14
examples/angular/simple/src/app/app.config.ts
Normal file
14
examples/angular/simple/src/app/app.config.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { provideHttpClient, withFetch } from '@angular/common/http'
|
||||
import {
|
||||
QueryClient,
|
||||
provideTanStackQuery,
|
||||
} from '@tanstack/angular-query-experimental'
|
||||
import { withDevtools } from '@tanstack/angular-query-experimental/devtools'
|
||||
import type { ApplicationConfig } from '@angular/core'
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [
|
||||
provideHttpClient(withFetch()),
|
||||
provideTanStackQuery(new QueryClient(), withDevtools()),
|
||||
],
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
@if (query.isPending()) {
|
||||
<div>Loading...</div>
|
||||
}
|
||||
@if (query.isError()) {
|
||||
<div>An error has occurred: {{ query.error().message }}</div>
|
||||
}
|
||||
@if (query.data(); as data) {
|
||||
<h1>{{ data.name }}</h1>
|
||||
<p>{{ data.description }}</p>
|
||||
<strong>👀 {{ data.subscribers_count }}</strong>
|
||||
<strong>✨ {{ data.stargazers_count }}</strong>
|
||||
<strong>🍴 {{ data.forks_count }}</strong>
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { ChangeDetectionStrategy, Component, inject } from '@angular/core'
|
||||
import { injectQuery } from '@tanstack/angular-query-experimental'
|
||||
import { HttpClient } from '@angular/common/http'
|
||||
import { lastValueFrom } from 'rxjs'
|
||||
|
||||
interface Response {
|
||||
name: string
|
||||
description: string
|
||||
subscribers_count: number
|
||||
stargazers_count: number
|
||||
forks_count: number
|
||||
}
|
||||
|
||||
@Component({
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
selector: 'simple-example',
|
||||
templateUrl: './simple-example.component.html',
|
||||
})
|
||||
export class SimpleExampleComponent {
|
||||
readonly #http = inject(HttpClient)
|
||||
|
||||
readonly query = injectQuery(() => ({
|
||||
queryKey: ['repoData'],
|
||||
queryFn: () =>
|
||||
lastValueFrom(
|
||||
this.#http.get<Response>('https://api.github.com/repos/tanstack/query'),
|
||||
),
|
||||
}))
|
||||
}
|
||||
BIN
examples/angular/simple/src/favicon.ico
Normal file
BIN
examples/angular/simple/src/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
13
examples/angular/simple/src/index.html
Normal file
13
examples/angular/simple/src/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>TanStack Query Angular simple example</title>
|
||||
<base href="/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
</body>
|
||||
</html>
|
||||
5
examples/angular/simple/src/main.ts
Normal file
5
examples/angular/simple/src/main.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { bootstrapApplication } from '@angular/platform-browser'
|
||||
import { appConfig } from './app/app.config'
|
||||
import { AppComponent } from './app/app.component'
|
||||
|
||||
bootstrapApplication(AppComponent, appConfig).catch((err) => console.error(err))
|
||||
1
examples/angular/simple/src/styles.css
Normal file
1
examples/angular/simple/src/styles.css
Normal file
@@ -0,0 +1 @@
|
||||
/* You can add global styles to this file, and also import other style files */
|
||||
Reference in New Issue
Block a user