Open History to see the last commit
1import {
2 ChangeDetectionStrategy,
3 Component,
4 inject,
5 input,
6 output,
7} from '@angular/core'
8import { injectQuery } from '@tanstack/angular-query-experimental'
9import { PostsQueries } from '../services/posts/queries'
10β
11@Component({
12 changeDetection: ChangeDetectionStrategy.OnPush,
13 selector: 'post',
14 templateUrl: './post.component.html',
15})
16export class PostComponent {
17 readonly #postsQueries = inject(PostsQueries)
18β
19 readonly setPostId = output<number>()
20 readonly postId = input(0)
21β
22 readonly postQuery = injectQuery(() => ({
23 ...this.#postsQueries.detail(this.postId()),
24 enabled: this.postId() > 0,
25 }))
26}