{"id":18471562,"url":"https://github.com/m310851010/nz-formly","last_synced_at":"2025-04-08T11:32:15.172Z","repository":{"id":54407566,"uuid":"522254124","full_name":"m310851010/nz-formly","owner":"m310851010","description":"基于ng-zorro-antd UI 扩展的ngx-formly组件库","archived":false,"fork":false,"pushed_at":"2025-01-11T12:31:02.000Z","size":1154,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-03T11:40:19.548Z","etag":null,"topics":["angular","angular13","angular14","ng-zorro-antd","ngx-formly"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/m310851010.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-08-07T15:44:06.000Z","updated_at":"2024-06-14T02:24:39.000Z","dependencies_parsed_at":"2023-12-12T15:30:38.601Z","dependency_job_id":"31276307-00cb-4d8b-9187-e933b60f566f","html_url":"https://github.com/m310851010/nz-formly","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m310851010%2Fnz-formly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m310851010%2Fnz-formly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m310851010%2Fnz-formly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m310851010%2Fnz-formly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/m310851010","download_url":"https://codeload.github.com/m310851010/nz-formly/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247773742,"owners_count":20993633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","angular13","angular14","ng-zorro-antd","ngx-formly"],"created_at":"2024-11-06T10:17:18.600Z","updated_at":"2025-04-08T11:32:13.560Z","avatar_url":"https://github.com/m310851010.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NzFormly\n\n基于ng-zorro-antd UI 扩展的ngx-formly组件库\n\n## demo\n\n![Alt Text](https://raw.githubusercontent.com/m310851010/nz-formly/main/static/img.png)\n\n\n## 用法\n\n### 安装\n\n```shell\nnpm i @ngx-formly/core @xmagic/nz-formly @xmagic/nzx-antd\n```\n\n### 导入模块\n\n```ts\nimport { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { NzFormlyModule } from '@xmagic/nz-formly';\nimport { FormlyModule } from '@ngx-formly/core';\n\n/**\n * ngx-formly的nz组件, 包含常用的表单组件\n */\n@NgModule({\n  imports: [\n    CommonModule,\n    // 使用nz-formly所必须的模块\n    FormlyModule,\n    NzFormlyModule\n  ]\n})\nexport class AppModule {}\n```\n\n\u003e 上面代码导入的是基础模块, 要用里面的组件需要导入对应的模块。\n\u003e \n\u003e 通常我们会创建一个`module`用来存放`nz-formly`用到的组件，例如：\n\n```ts\nimport { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { NzFormlyModule } from '@xmagic/nz-formly';\nimport { FormlyModule } from '@ngx-formly/core';\nimport { FormlyCommonModule } from '@xmagic/nz-formly/common';\nimport { FormlyNzCheckboxModule } from '@xmagic/nz-formly/checkbox';\nimport { FormlyNzInputModule } from '@xmagic/nz-formly/input';\nimport { FormlyNzDatePickerModule } from '@xmagic/nz-formly/date-picker';\nimport { FormlyNzDateRangePickerModule } from '@xmagic/nz-formly/date-range-picker';\nimport { FormlyNzRadioModule } from '@xmagic/nz-formly/radio';\nimport { FormlyNzGridModule } from '@xmagic/nz-formly/grid';\nimport { FormlyNzFormFieldModule } from '@xmagic/nz-formly/field-wrapper';\nimport { FormlyNzTextareaModule } from '@xmagic/nz-formly/textarea';\nimport { FormlyNzTextValueModule } from '@xmagic/nz-formly/text-value';\nimport { FormlyNzSelectModule } from '@xmagic/nz-formly/select';\nimport { FormlyNzSwitchModule } from '@xmagic/nz-formly/switch';\n\n/**\n * ngx-formly的nz组件, 包含常用的表单组件\n */\n@NgModule({\n  exports: [\n    CommonModule,\n    FormlyModule,\n    NzFormlyModule,\n    FormlyCommonModule,\n    FormlyNzCheckboxModule,\n    FormlyNzInputModule,\n    FormlyNzDatePickerModule,\n    FormlyNzDateRangePickerModule,\n    FormlyNzRadioModule,\n    FormlyNzGridModule,\n    FormlyNzFormFieldModule,\n    FormlyNzTextareaModule,\n    FormlyNzTextValueModule,\n    FormlyNzSelectModule,\n    FormlyNzSwitchModule\n    // 其他组件\n  ]\n})\nexport class SharedFormlyModule {}\n```\n### 模板的写法\n\n仍然采用 `ngx-formly`的原生用法，`nz-formly`扩展了便捷的操作\n\n```html\n\u003cform nz-form [formGroup]=\"form\" (ngSubmit)=\"submit()\"\u003e\n  \u003cformly-form formly-box [model]=\"model\" [fields]=\"fields\" [options]=\"options\" [form]=\"form\"\u003e\n    \u003cng-template named=\"icon-button\"\u003e\n      \u003cbutton nz-button nzType=\"primary\" nzSearch\u003e\u003ci nz-icon nzType=\"search\"\u003e\u003c/i\u003e\u003c/button\u003e\n    \u003c/ng-template\u003e\n  \u003c/formly-form\u003e\n\u003c/form\u003e\n```\n\n### 组件的写法\n\n```ts\n@Component({\n  ...\n})\nexport class AppComponent {\n  form = new FormGroup({});\n  model = { awesome: [1, 2], switchDemoKey: 'XX', myText2: 'some text' };\n  options: FormlyFormOptions = {\n    formState: {\n      labelNzFlex: '100px',\n      controlNzFlex: 'auto'\n    }\n  };\n  fields: NzField[] = [\n    {\n      key: 'name',\n      type: 'input',\n      props: {\n        label: '名称',\n        required: true,\n        nzSearch: true,\n        nzAddOnAfterName: 'icon-button'\n      }\n    },\n    {\n      key: 'awesome',\n      type: 'checkbox',\n      props: {\n        label: '渠道',\n        options: [\n          { label: '网络', value: 1 },\n          { label: '代理商', value: 2 },\n          { label: '其他', value: 3 }\n        ]\n      }\n    },\n    {\n      key: 'radioKey',\n      type: 'radio',\n      props: {\n        label: '单选',\n        options: [\n          { label: '网络', value: 1 },\n          { label: '代理商', value: 2 },\n          { label: '其他', value: 3 }\n        ]\n      }\n    },\n    {\n      key: 'switchDemoKey',\n      type: 'switch',\n      props: {\n        label: '开关',\n        nzxCheckedValue: 'XX',\n        nzxUnCheckedValue: 'YY'\n      }\n    },\n    {\n      key: 'comment',\n      type: 'textarea',\n      props: {\n        label: '评论',\n        rows: 2,\n        maxLength: 100,\n        nzMaxCharacterCount: 100\n      }\n    },\n    {\n      key: 'status',\n      type: 'select',\n      props: {\n        label: '状态',\n        nzAllowClear: true,\n        options: [\n          { label: 'AA', value: 'aa' },\n          { label: 'BB', value: 'bb' }\n        ]\n      }\n    },\n    {\n      key: 'myText',\n      type: 'text',\n      props: {\n        label: '文本'\n      }\n    },\n    {\n      key: 'myText2',\n      type: 'text',\n      props: {\n        label: '文本2'\n      }\n    }\n  ];\n\n  submit() {\n    if (this.form.valid) {\n      alert(JSON.stringify(this.model));\n    }\n  }\n}\n```\n\n## 运行环境\n\n- ndoejs 14+\n- angular 13.0+\n- ng-zorro-antd 13.0+\n- @ngx-formly/core 6.0+\n- @xmagic/nzx-antd 13.0+ (angular 14 请安装@xmagic/nzx-antd 14.0+)\n\n### License\n\nThe MIT License (see the [LICENSE](https://github.com/m310851010/nz-formly/blob/master/LICENSE) file for the full text)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm310851010%2Fnz-formly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm310851010%2Fnz-formly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm310851010%2Fnz-formly/lists"}