Open History to see the last commit
1import { Injectable, inject, signal } from '@angular/core'
2import type { FieldApi, FormErrorTypes } from '@tanstack/form-core'
3β
4@Injectable({ providedIn: null })
5export class TanStackFieldInjectable<
6 TFieldValue,
7 TFieldName = any,
8 TFieldError = any,
9 TFormData = any,
10 TFormErrorTypes extends FormErrorTypes = any,
11> {
12 _api = signal<
13 FieldApi<TFieldName, TFieldValue, TFieldError, TFormData, TFormErrorTypes>
14 >(null as never)
15β
16 get api() {
17 return this._api()
18 }
19}
20β
21/** Injects the field provided by an ancestor `tanstack-app-field` directive. */
22export function injectField<
23 TFieldValue,
24>(): TanStackFieldInjectable<TFieldValue> {
25 return inject(TanStackFieldInjectable<TFieldValue>)
26}