# NG Dynamic Forms
[](https://badge.fury.io/js/%40ng-dynamic-forms%2Fcore)
[](https://travis-ci.org/udos86/ng-dynamic-forms)
[](https://coveralls.io/github/udos86/ng-dynamic-forms)
[](https://deepscan.io/dashboard/#view=project&pid=562&bid=912)
[](https://npmjs.org/package/@ng-dynamic-forms/core)
***
:bangbang:09-14-2017: **@ng2-dynamic-forms has been renamed to @ng-dynamic-forms**:bangbang:
***
NG Dynamic Forms is a **rapid form development library** based on the official Angular
[**dynamic forms guide**](https://angular.io/docs/ts/latest/cookbook/dynamic-form.html).
It **fully automates form UI creation** by introducing a set of maintainable **form control models** and **dynamic form control components**
**Out of the box support** is provided for all popular UI libraries including **[Bootstrap](http://getbootstrap.com)**, **[Foundation](http://foundation.zurb.com/)**, **[Ionic](http://ionicframework.com/)**,
**[Kendo](http://www.telerik.com/kendo-angular-ui)**, **[Material](https://material.angular.io/)**, **[NG Bootstrap](https://ng-bootstrap.github.io/#/home)** and **[PrimeNG](http://www.primefaces.org/primeng/#/)**.
[**Explore it**](http://ng2-dynamic-forms.udos86.de/sample/index.aot.html) live in action!
## Table of Contents
- [Getting Started](#getting-started)
- [Running the Example](#running-the-example)
- [Basic Usage](#basic-usage)
- [UI Modules](#ui-modules)
- [Form Groups](#form-groups)
- [Form Arrays](#form-arrays)
- [Form Layouts](#form-layouts)
- [Form Control Events](#form-control-events)
- [Custom Templates](#custom-templates)
- [Custom Validators](#custom-validators)
- [Validation Messaging](#validation-messaging)
- [JSON Export / Import](#json-export--import)
- [Updating Form Models](#updating-form-models)
- [Disabling / Enabling Form Controls](#disabling--enabling-form-controls)
- [Text Masks](#text-masks)
- [Related Form Controls](#related-form-controls)
- [Autocompletion](#autocompletion)
- [AOT Compilation](#aot-compilation)
- [FAQ](#faq)
- [Appendix](#appendix)
## Getting Started
**1. Install the core package**:
```
npm install @ng-dynamic-forms/core -S
```
**2. Choose your [UI library](#ui-modules)** and **install the appropriate package**:
```
npm install @ng-dynamic-forms/ui-bootstrap -S
```
**3.** When using **SystemJS**, update your configuration to **import the corresponding UMD bundles**:
```ts
System.config({
paths: {
"npm:": "node_modules/"
},
map: {
// ...all the rest (Angular, RxJS, etc.)
"@ng-dynamic-forms/core": "npm:@ng-dynamic-forms/core/bundles/core.umd.js",
"@ng-dynamic-forms/ui-bootstrap": "npm:@ng-dynamic-forms/ui-bootstrap/bundles/ui-bootstrap.umd.js",
}
});
```
## Running the Sample
**1. Clone the Git repository**:
```
git clone https://github.com/udos86/ng-dynamic-forms.git
```
**2. Install the npm dependencies**:
```
npm install
```
**3. Build the library**:
```
npm run build:packages
```
**4. Transpile the sample code**:
```
npm run watch:sample
```
**5. Run the application**:
```
npm start
```
## Basic Usage
**1. Import** `DynamicFormsCoreModule` **via** `forRoot()` **and a UI module**:
```ts
import { DynamicFormsCoreModule } from "@ng-dynamic-forms/core";
import { DynamicFormsBootstrapUIModule } from "@ng-dynamic-forms/ui-bootstrap";
// ...
@NgModule({
imports: [
ReactiveFormsModule,
DynamicFormsCoreModule.forRoot(),
DynamicFormsBootstrapUIModule,
// ...
]
})
export class AppModule {}
```
**2. Define your form model**:
```ts
import {
DynamicFormControlModel,
DynamicCheckboxModel,
DynamicInputModel,
DynamicRadioGroupModel
} from "@ng-dynamic-forms/core";
export const MY_FORM_MODEL: DynamicFormControlModel[] = [
new DynamicInputModel({
id: "sampleInput",
label: "Sample Input",
maxLength: 42,
placeholder: "Sample input"
}),
new DynamicRadioGroupModel