@fieldia/angular

中文文档
0.36.1发布于 2026/10/28MITTypeScriptES Module近 30 天下载 3924

Angular binding for Fieldia: over the plain-DOM viewer, with custom fields as Angular components and slots as ng-templates.

原始使用文档

@fieldia/angular

Fieldia forms in Angular 21 and 22: a standalone component over @fieldia/viewer, so a page looks and behaves the same as in any other framework.

npm install @fieldia/angular
import { Component } from '@angular/core';
import { FieldiaFormComponent } from '@fieldia/angular';
import { createMemoryDataSource } from '@fieldia/core';
import page from './customer.page.json';

@Component({
  selector: 'app-customer',
  imports: [FieldiaFormComponent],
  template: `<fieldia-form [page]="page" [dataSource]="dataSource" [recordId]="1" skin="underline" />`,
})
export class CustomerComponent {
  readonly page = page;
  readonly dataSource = createMemoryDataSource();
}

Custom fields can be Angular components (fieldTypes), slot content goes in <ng-template fieldiaSlot="name">, and formState(form) gives you a form's state as a signal. The viewer's options are inputs of the same names, but for the app's translator: [translator], because a [translate] binding goes to the element's own HTML attribute. A list page opens a row through the (openRecord) output.

The form's events are outputs: (fieldChange) — not (change), which on a component's element would hear its boxes' own change events too — (save), (send), (step) and (run). An output cannot answer, so the app's answer to a button or a call step is the [answer] input; (action) still tells every call:

@Component({
  imports: [FieldiaFormComponent],
  template: `<fieldia-form [page]="page" [dataSource]="dataSource" [pages]="pages"
    [answer]="answer" (fieldChange)="changed($event)" (save)="saved($event)" (run)="ran($event)" />`,
})
export class OrderComponent {
  readonly answer = async ({ action, values }: ActionRequest) =>
    action === 'check_stock' ? { values: { price: await priceOf(values['product']) } } : undefined;
}

The viewer's host and onOpen are [actionHost] and [openPage]; the handle from (ready) has on, setValues and run.

A page with continueLater opens a draft kept on your server by its key — [resume]="route.snapshot.queryParamMap.get('resume') ?? undefined", the key the link Continue later gave — and (draft) is told of each draft kept. A new [resume] opens that draft, as a new [recordId] opens that record.

A page that fills fields from its link (prefill) reads the browser's address; an app rendered on a server, or shown inside another page, gives the link it knows — [url]="router.url", an address, or [url]="{ agent: 'mona' }". A new [url] starts the form from it again.

Before your app leaves the form, ask its one check: await handle.form.leave() in a route's canDeactivate, before removing <fieldia-form>, and before changing an input that mounts it again (page, form, dataSource, recordId, resume, url, user, context, dir, locale, labels, fieldTypes, the names in functions). Angular destroys it at once, so nothing else can keep the person there. It waits for a save on its way, then asks "Discard your changes?" only when their work is at risk, and answers false when they choose to stay. [warnOnLeave]="true" has the browser's own Back, Reload or a closed tab ask first while there is a change not saved.

A part that throws as it is drawn or brought up to date — a field's component, a slot's content, the app's widget, a map — shows a small box that names it, and the rest of the form goes on; (partError) hears { error, where } (not (error), the DOM's own event). A page the viewer refuses says why in the form's place, (partError) hears it with { stage: 'draw', part: 'page' }, and the app goes on; one it draws whose whole check finds mistakes, { stage: 'check', part: 'page', warning: true } (0.36; refused from 0.37). MIT licensed.

版本与发布记录

@fieldia/angular 共发布 49 个版本,首次发布于 2026/10/02;过去 12 个月发布了 49 个版本。

版本发布日期距今
0.36.1latest2026/10/2817 天前
0.36.02026/10/2817 天前
0.35.32026/10/2818 天前
0.35.22026/10/2718 天前
0.35.12026/10/2619 天前
0.35.02026/10/2619 天前

关于 @fieldia/angular 的常见问题

@fieldia/angular 是什么?

Angular binding for Fieldia: over the plain-DOM viewer, with custom fields as Angular components and slots as ng-templates.

如何安装 @fieldia/angular?

在项目目录运行 npm install @fieldia/angular,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@angular/core(^21.0.0 || ^22.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@fieldia/angular 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fieldia/angular 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@fieldia/angular 可以商用吗?

@fieldia/angular 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fieldia/angular 的下载量有多少?

根据 npm 官方下载统计,@fieldia/angular 在 2026/10/15 – 2026/11/13 这 30 天内被下载 3,924 次,日均约 131 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fieldia/angular 还在维护吗?

最新版本 0.36.1 发布于 2026/10/28(17 天前);至今共发布 49 个版本,其中过去 12 个月发布了 49 个;首次发布于 2026/10/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。