Giter Site home page Giter Site logo

harshitchhipa / ngx-formly Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ngx-formly/ngx-formly

1.0 2.0 0.0 19.4 MB

JSON powered / Dynamic forms for Angular

Home Page: https://formly.dev

License: MIT License

JavaScript 3.75% TypeScript 95.85% HTML 0.30% CSS 0.10%

ngx-formly's Introduction


JSON powered / Dynamic forms in Angular

Npm version Downloads Gitter Build Status Twitter


Formly is a dynamic (JSON powered) form library for Angular that bring unmatched maintainability to your application's forms.

Features

  • ๐Ÿ”ฅ Automatic forms generation
  • ๐Ÿ“ Easy to extend with custom field type, validation, wrapper and extension.
  • โšก๏ธ Support multiple schemas:
    • Formly Schema (core)
    • JSON Schema
  • ๐Ÿ˜ A bunch of themes, out of the box!
  • ๐Ÿ’ช Build on top of Angular Reactive Forms
  • ๐Ÿ˜ฑ Drag and Drop Editor (coming ๐Ÿ”œ)

Supported UI libs

UI
Bootstrap Demo StackBlitz
Material2 Demo StackBlitz
Ionic Demo StackBlitz
PrimeNG Demo StackBlitz
Kendo Demo StackBlitz
NativeScript

Which Version to use?

Angular version Formly version
Angular >= 7 @ngx-formly/[email protected]
Angular >= 6 @ngx-formly/[email protected]
Angular >= 5 @ngx-formly/[email protected]
Angular >= 4 @ngx-formly/[email protected]
Angular >= 2 [email protected]

Quick links

Quick Start

Follow these steps to get started with Ngx 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:

UI Npm package name NgModule
Bootstrap @ngx-formly/bootstrap FormlyBootstrapModule
Material2 @ngx-formly/material FormlyMaterialModule
Ionic @ngx-formly/ionic FormlyIonicModule
PrimeNG @ngx-formly/primeng FormlyPrimeNGModule
Kendo @ngx-formly/kendo FormlyKendoModule
NativeScript @ngx-formly/nativescript FormlyNativescriptModule
  npm install @ngx-formly/<package-name> --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';

/**
 * - Bootstrap:     import {FormlyBootstrapModule} from '@ngx-formly/bootstrap';
 * - Material2:     import {FormlyMaterialModule} from '@ngx-formly/material';
 * - Ionic:         import {FormlyIonicModule} from '@ngx-formly/ionic'
 * - PrimeNG:       import {FormlyPrimeNGModule} from '@ngx-formly/primeng';
 * - Kendo:         import {FormlyKendoModule} from '@ngx-formly/kendo';
 * - NativeScript:  import {FormlyNativescriptModule} from '@ngx-formly/nativescript';
 */
import {FormlyBootstrapModule} from '@ngx-formly/bootstrap';

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

    /**
     * - Bootstrap:    FormlyBootstrapModule
     * - Material2:    FormlyMaterialModule
     * - Ionic:        FormlyIonicModule
     * - PrimeNG:      FormlyPrimeNGModule
     * - Kendo:        FormlyKendoModule
     * - NativeScript: FormlyNativescriptModule
     */
    FormlyBootstrapModule,
  ],
})
export class AppModule {}

4. 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"></formly-form>
      <button type="submit" class="btn btn-default">Submit</button>
    </form>
  `,
})
export class AppComponent {
  form = new FormGroup({});
  model = { email: '[email protected]' };
  fields: FormlyFieldConfig[] = [{
    key: 'email',
    type: 'input',
    templateOptions: {
      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.

Using with Angular-CLI

@ngx-formly/schematics provides CLI commands for setting up a project and eventually generating other features (e.g. wrapper components). Built on top of Schematics, this tool integrates with the Angular CLI.

Installation

Install @ngx-formly/schematics from npm:

npm install @ngx-formly/schematics --save-dev

Default Schematics Collection

To use @ngx-formly/schematics as the default collection in your Angular CLI project, add it to your angular.json:

ng config cli.defaultCollection @ngx-formly/schematics

The collection schema defines the available schematics to run.

The @ngx-formly/schematics extend the default @schematics/angular collection and so all existing Angular CLI commands are available. If you want to set defaults for schematics such as generating components with scss file, you must change the schematics package name from @schematics/angular to @ngx-formly/schematics in angular.json:

"schematics": {
  "@ngx-formly/schematics:component": {
    "styleext": "scss"
  }
}

Quick Start with Schematics

Install @angular/forms and @ngx-formly/core packages and choose a UI theme to install:

  ng add @ngx-formly/schematics --ui-theme=material

Roadmap

See the issues labeled enhancement

Credits

Contributors

Thanks goes to these wonderful people:

aitboudadmohammedzamakhandivyakumarjaincouzicjuristrfranzeal

beemanklemenoslajsamtsaithorgoddwaldrumKrustie101

MarcosEllysryanjerskineDevqonAlexTalcuranewsashbhaidar

DayvissonintellixenricouniurbFritzHerbersjrgleasonjohannesjo

jdpnielsenTheMcMurderkenistewardkentcdoddsLennardWesterveldLucasJAlba

lucienbertinwaffle-ironmathijshooglandNanFengCheongPoujaRiron

Ronen-devblowsiethm1118Tom-Vdanielcrispfrancisco-sanchez-molina

n3xus

ngx-formly's People

Contributors

aitboudad avatar mohammedzamakhan avatar divyakumarjain avatar couzic avatar juristr avatar franzeal avatar beeman avatar klemenoslaj avatar samtsai avatar thorgod avatar dwaldrum avatar intellix avatar krustie101 avatar marcosellys avatar ryanjerskine avatar devqon avatar alextalcura avatar alex-novikov-1990 avatar bhaidar avatar dayvisson avatar enricouniurb avatar fritzherbers avatar jrgleason avatar johannesjo avatar jdpnielsen avatar themcmurder avatar kenisteward avatar lennardwesterveld avatar logvinoleg89 avatar lucasjalba avatar

Stargazers

Mrinal Tyagi avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.