Skip to content

Commit 0add630

Browse files
committed
docs(angular-query): add rxjs example
1 parent 8727d97 commit 0add630

24 files changed

+509
-28
lines changed

docs/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,10 @@
10451045
{
10461046
"label": "Angular Router",
10471047
"to": "framework/angular/examples/router"
1048+
},
1049+
{
1050+
"label": "RxJS autocomplete",
1051+
"to": "framework/angular/examples/rxjs"
10481052
}
10491053
]
10501054
}

examples/angular/basic/src/app/components/post.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<div>
33
<a (click)="setPostId.emit(-1)" href="#"> Back </a>
44
</div>
5-
@if (postQuery.status() === 'pending') {
5+
@if (postQuery.isPending()) {
66
Loading...
7-
} @else if (postQuery.status() === 'error') {
8-
Error: {{ postQuery.error()?.message }}
7+
} @else if (postQuery.isError()) {
8+
Error: {{ postQuery.error().message }}
99
}
1010
@if (postQuery.data(); as post) {
1111
<h1>{{ post.title }}</h1>

examples/angular/basic/src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
5-
<title>Angular Query basic example</title>
5+
<title>TanStack Query Angular basic example</title>
66
<base href="/" />
77
<meta name="viewport" content="width=device-width, initial-scale=1" />
88
<link rel="icon" type="image/x-icon" href="favicon.ico" />

examples/angular/router/src/app/components/post.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<div>
33
<a routerLink="/" href="#">Back</a>
44
</div>
5-
@if (postQuery.status() === 'pending') {
5+
@if (postQuery.isPending()) {
66
Loading...
7-
} @else if (postQuery.status() === 'error') {
8-
Error: {{ postQuery.error()?.message }}
7+
} @else if (postQuery.isError()) {
8+
Error: {{ postQuery.error().message }}
99
}
1010
@if (postQuery.data(); as post) {
1111
<h1>{{ post.title }}</h1>

examples/angular/router/src/app/components/post.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import { PostsService } from '../services/posts-service'
2020
export default class PostComponent {
2121
#postsService = inject(PostsService)
2222

23+
// The Angular router will automatically bind postId
24+
// as `withComponentInputBinding` is added to `provideRouter`.
25+
// See https://angular.dev/api/router/withComponentInputBinding
2326
postId = input.required({
2427
transform: numberAttribute,
2528
})

examples/angular/router/src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
5-
<title>Angular Query router example</title>
5+
<title>TanStack Query Angular router example</title>
66
<base href="/" />
77
<meta name="viewport" content="width=device-width, initial-scale=1" />
88
<link rel="icon" type="image/x-icon" href="favicon.ico" />
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "Node.js",
3+
"image": "mcr.microsoft.com/devcontainers/javascript-node:18"
4+
}

examples/angular/rxjs/.eslintrc.cjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// @ts-check
2+
3+
/** @type {import('eslint').Linter.Config} */
4+
const config = {}
5+
6+
module.exports = config

examples/angular/rxjs/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# TanStack Query Angular RxJS Example
2+
3+
To run this example:
4+
5+
- `npm install` or `yarn` or `pnpm i` or `bun i`
6+
- `npm run start` or `yarn start` or `pnpm start` or `bun start`

examples/angular/rxjs/angular.json

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"cli": {
5+
"packageManager": "pnpm",
6+
"analytics": false,
7+
"cache": {
8+
"enabled": false
9+
}
10+
},
11+
"newProjectRoot": "projects",
12+
"projects": {
13+
"basic": {
14+
"projectType": "application",
15+
"schematics": {
16+
"@schematics/angular:component": {
17+
"inlineTemplate": true,
18+
"inlineStyle": true,
19+
"skipTests": true
20+
},
21+
"@schematics/angular:class": {
22+
"skipTests": true
23+
},
24+
"@schematics/angular:directive": {
25+
"skipTests": true
26+
},
27+
"@schematics/angular:guard": {
28+
"skipTests": true
29+
},
30+
"@schematics/angular:interceptor": {
31+
"skipTests": true
32+
},
33+
"@schematics/angular:pipe": {
34+
"skipTests": true
35+
},
36+
"@schematics/angular:resolver": {
37+
"skipTests": true
38+
},
39+
"@schematics/angular:service": {
40+
"skipTests": true
41+
}
42+
},
43+
"root": "",
44+
"sourceRoot": "src",
45+
"prefix": "app",
46+
"architect": {
47+
"build": {
48+
"builder": "@angular-devkit/build-angular:application",
49+
"options": {
50+
"outputPath": "dist/basic",
51+
"index": "src/index.html",
52+
"browser": "src/main.ts",
53+
"polyfills": ["zone.js"],
54+
"tsConfig": "tsconfig.app.json",
55+
"assets": ["src/favicon.ico", "src/mockServiceWorker.js"],
56+
"styles": [],
57+
"scripts": []
58+
},
59+
"configurations": {
60+
"production": {
61+
"budgets": [
62+
{
63+
"type": "initial",
64+
"maximumWarning": "500kb",
65+
"maximumError": "1mb"
66+
},
67+
{
68+
"type": "anyComponentStyle",
69+
"maximumWarning": "2kb",
70+
"maximumError": "4kb"
71+
}
72+
],
73+
"outputHashing": "all"
74+
},
75+
"development": {
76+
"optimization": false,
77+
"extractLicenses": false,
78+
"sourceMap": true
79+
}
80+
},
81+
"defaultConfiguration": "production"
82+
},
83+
"serve": {
84+
"builder": "@angular-devkit/build-angular:dev-server",
85+
"configurations": {
86+
"production": {
87+
"buildTarget": "basic:build:production"
88+
},
89+
"development": {
90+
"buildTarget": "basic:build:development"
91+
}
92+
},
93+
"defaultConfiguration": "development"
94+
},
95+
"extract-i18n": {
96+
"builder": "@angular-devkit/build-angular:extract-i18n",
97+
"options": {
98+
"buildTarget": "basic:build"
99+
}
100+
}
101+
}
102+
}
103+
}
104+
}

0 commit comments

Comments
 (0)