This package simplifies Angular form creation with full Angular reactive capabilities by offering a straightforward class configuration. It leverages Angular Material, utilizing material themes for enhanced functionality.
Configure your form directly on NgxFormLib or play with forms on Stackblitz
- In your angular project run command
npm install --save ngx-form-lib
and install the package. - This library use Angular material for themes. So, if you have already setup
Angular material
skip step 4. - You also need to install
peer dependencies
. Installing npm peer dependencies. - Setup angular material in your project. Getting started guide.
- Import
BrowserAnimationModule
inapp.module.ts
.
// ... Other imports
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
@NgModule({
imports: [
...,
BrowserAnimationsModule
],
...,
})
export class AppModule { }
- Import
FormLibModule
fromngx-form-lib
and add it into the imports array of your module.
import { NgModule } from '@angular/core';
import { FormLibModule } from 'ngx-form-lib';
import { CommonModule } from '@angular/common';
@NgModule({
declarations: [HomeComponent],
imports: [
CommonModule,
FormLibModule,
],
})
export class HomeModule {}
- Create a constant file with form configuration. You can directly create form configuration on NgxFormLib webpage and use it in your projects. IDE support will provide with autofill for various properties.
import { ParentConfig, Input, Field, Config } from "ngx-form-lib";
export const CONFIG: Config = {
header: 'Form Header',
parentConfig: new ParentConfig({
appearance: 'fill',
color: 'primary',
}),
sections: [
{
sectionHeader: 'Section Header',
fields: [
new Input({
subType: 'text',
field: new Field({
type: 'input',
name: 'money',
label: 'Enter your name',
order: 1,
classes: ['ngf-col-12'],
}),
}),
],
},
],
};
- Bind the configuration with
config
property ofngx-for-lib
component.
<ngx-form-lib [config]="CONFIG"></ngx-form-lib>
If you find breaking style with material form just install peer dependencies
manually and rerun the project.
- Input
- Textarea
- Checkbox
- Radio
- Button
- Dropdown
- Dynamic components
- Field Dependencies
- Facets implementations (hidden, disable, set value)
- Form dependencies
To get more help, issues or any suggestions for the ngx-form-lib
mail to navdeep.dev2510@gmail.com
with subject ngx-form-lib
.