fork of hey-api/openapi-ts because I need some additional things
1import { JsonPipe } from '@angular/common';
2import { Component, inject, signal } from '@angular/core';
3import { RouterOutlet } from '@angular/router';
4
5import { PetServiceResources } from '../../client';
6
7@Component({
8 host: { ngSkipHydration: 'true' },
9 imports: [RouterOutlet, JsonPipe],
10 selector: 'app-demo',
11 styleUrl: './demo.css',
12 templateUrl: './demo.html',
13})
14export class Demo {
15 #petResources = inject(PetServiceResources);
16
17 petId = signal(0);
18
19 // if you don't use `asClass`, you can simply remove the inject and use `getPetByIdResource(...)` here
20 pet = this.#petResources.getPetById(() => ({
21 path: {
22 petId: this.petId(),
23 },
24 }));
25
26 onGetPetById = async () => {
27 this.petId.set(Math.floor(Math.random() * (10 - 1 + 1) + 1));
28 };
29}