ng-form-factory
Generate Angular Forms for you !
Last updated 5 days ago by grandschtroumpf .
Original npm · Tarball · package.json
$ cnpm install ng-form-factory 
SYNC missed versions from official npm registry.

Form Factory

Generate Angular Forms for you !

Get started

npm install ng-form-factory

In your app.module.ts

@NgModule({
  imports: [
    FormFactoryModule.forRoot()
  ]
})

In app.component.ts

const schema = {
  form: 'control',
  load: () => import('./text.component').then(c => c.TextFormComponent),
};
@Component({
  selector: 'app-root',
  template: '<form-outlet [form]="form" [schema]="schema"/>',
})
export class AppComponent implements FormOutlet {
  // Generate the right Form depending on the schema (in this case FormControl)
  form = createForms(schema, 'some text');
  schema: FormSchema;
}

The schema is going to lazy load the component TextFormComponent and pass it the form.

Let's create the component in text.component.ts:

import { Component } from '@angular/core';
import { FormControl, ReactiveFormsModule } from '@angular/forms';
import { FormOutlet, FormSchema } from 'ng-form-factory';

@Component({
  selector: 'form-text',
  template: '<input [formControl]="form" />',
})
export class TextFormComponent implements FormOutlet {
  form: FormControl;
  schema: FormSchema;
}

@Ngodule({
  declarations: [TextFormComponent],
  import: [ReactiveFormsModule]
})
export class TextFormModule {}

FormOutlet make sure that the component implements a form & a schema

Serve the app, you should see the form-text beeing lazy loaded automatically.

Current Tags

  • 0.0.18                                ...           latest (5 days ago)

18 Versions

  • 0.0.18                                ...           5 days ago
  • 0.0.17                                ...           5 days ago
  • 0.0.16                                ...           6 days ago
  • 0.0.15                                ...           12 days ago
  • 0.0.14                                ...           5 months ago
  • 0.0.13                                ...           5 months ago
  • 0.0.12                                ...           5 months ago
  • 0.0.11                                ...           5 months ago
  • 0.0.10                                ...           5 months ago
  • 0.0.9                                ...           5 months ago
  • 0.0.8                                ...           9 months ago
  • 0.0.7                                ...           9 months ago
  • 0.0.6                                ...           9 months ago
  • 0.0.5                                ...           9 months ago
  • 0.0.4                                ...           9 months ago
  • 0.0.3                                ...           9 months ago
  • 0.0.2                                ...           9 months ago
  • 0.0.1                                ...           9 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 22
Last Month 29
Dependencies (3)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2016 © taobao.org |