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