0.0.9 • Published 7 years ago

@jaspero/ng2-form-builder v0.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

Build Status NPM Version

NG2 Form-Builder

This library provides a faster and cleaner way to use Angular 2 Reactive Forms through typescript decorators.

Setup

Import FormBuilderModule in your @NgModule and you're good to go:

@NgModule({
    imports: [
        FormBuilderModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule {}

How to use

To use this library simply create a class and add @JasperoBuilder.dec() decorators to each property:

export class User {
    @JasperoBuilder.dec({initial: ''})
    username: string;
    @JasperoBuilder.dec({initial: ''})
    password: string;
}

The dec() method accepts the same arguments as new FormControl() does and creates the FormControl in the background.

Then in your component create the FormGroup like this:

export class AppComponent {
    constructor(private _jb: JasperoBuilder) {}
    
    userForm: any;

    ngOnInit() {
        // You can also instantiate the class with values
        this.useForm = this._jb.createForm(new User());
    }
}
0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago