zronn / ngx-formly

JavaScript powered FORMS for Angular 2.x and above

Home Page:https://formly-js.github.io/ngx-formly

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

angular-formly logo

@ngx-formly

Angular Style Guide All Contributors Stories in Ready

Status: Build Status npm version devDependencies Status Package Quality Known Vulnerabilities codecov.io

Links: Gitter PRs Welcome

@ngx-formly is an Angular module which has a Components to help customize and render JavaScript/JSON configured forms. The formly-form Component and the FormlyConfig service are very powerful and bring unmatched maintainability to your application's forms.

Quick Start

Follow these steps to get started with ng-formly. Also check out our demos for further examples.

1. Install @angular/forms and @ngx-formly/core packages:

  npm install @angular/forms @ngx-formly/core --save

2. Choose and install your UI (pre-defined types/templates) package:

  npm install @ngx-formly/material --save
  • Bootstrap:
      npm install @ngx-formly/bootstrap --save

3. Import the FormlyModule and UI (pre-defined types/templates):

import {NgModule} from '@angular/core';
import {ReactiveFormsModule} from '@angular/forms';
import {FormlyModule} from '@ngx-formly/core';
import {FormlyBootstrapModule} from '@ngx-formly/bootstrap';

// for material2 import `FormlyMaterialModule`:
// import {FormlyMaterialModule} from '@ngx-formly/material';

@NgModule({
  imports: [
    ...,
    ReactiveFormsModule,
    FormlyModule.forRoot(),
    FormlyBootstrapModule,

    // for material2 use:
    // FormlyMaterialModule
  ],
})
export class AppModule {}

3. Define the form config in your component:

import {Component} from '@angular/core';
import {FormGroup} from '@angular/forms';
import {FormlyFieldConfig} from '@ngx-formly/core';

@Component({
  selector: 'app',
  template: `
    <form [formGroup]="form" (ngSubmit)="submit(model)">
      <formly-form [form]="form" [fields]="fields" [model]="model">
        <button type="submit" class="btn btn-default">Submit</button>
      </formly-form>
    </form>
  `,
})
export class AppComponent {
  form = new FormGroup({});
  model = { email: 'email@gmail.com' };
  fields: FormlyFieldConfig[] = [{
    key: 'email',
    type: 'input',
    templateOptions: {
      type: 'email',
      label: 'Email address',
      placeholder: 'Enter email',
      required: true,
    }
  }];

  submit(model) {
    console.log(model);
  }
}

From there, it's just JavaScript. Allowing for DRY, maintainable, reusable forms.

Roadmap

See the issues labeled enhancement

Thanks

A special thanks to Kent C. Dodds for giving me opportunity to work on this. This library is maintained (with love) by me, Mohammed Zama Khan. Thanks to all contributors! If you're trying to find angular-formly, go here

Contributors

Thanks goes to these wonderful people (emoji key):


Zama Khan Mohammed

πŸ“– πŸ’» πŸ‘€ πŸ’ πŸš‡ πŸ”§

Abdellatif Ait boudad

πŸ’» πŸ“– ⚠️ πŸ‘€ πŸ’

divyakumarjain

πŸ’» πŸ“– πŸ”Œ πŸ‘€ πŸ’

Pouja

πŸ’» πŸ‘€

Caleb Kniffen

πŸ›

Riron

πŸ›

Thiago Lacerda

πŸ›

danielcrisp

πŸ› πŸ’»

Tony Franzese

πŸ› πŸ’»

Jackie Gleason

πŸ› πŸ’»

ampsarfraz

πŸ›

Krustie101

πŸ› πŸ’»

ultimafirez

πŸ›

This project follows the all-contributors specification. Contributions of any kind welcome!

About

JavaScript powered FORMS for Angular 2.x and above

https://formly-js.github.io/ngx-formly

License:MIT License


Languages

Language:TypeScript 97.2%Language:JavaScript 2.8%