npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@savajravi/angular-dynamic-form

v1.0.1

Published

A powerful and flexible dynamic form component for Angular applications

Downloads

12

Readme

Angular Dynamic Form Library

A flexible and reusable dynamic form component for Angular applications that allows you to create forms programmatically using configuration objects.

Features

  • 🚀 Dynamic Form Generation: Create forms from configuration objects
  • 📱 Responsive Layouts: Support for vertical, horizontal, and grid layouts
  • 🎨 Customizable Styling: Easy to customize with CSS classes
  • Built-in Validation: Comprehensive validation support
  • 🔄 Reactive Forms: Built on Angular Reactive Forms
  • 🎯 Multiple Field Types: Text, email, number, textarea, select, multiselect, checkbox, radio, date, file, and more
  • 🌐 API Integration: Load select options from APIs
  • 📦 NPM Package: Easy to install and use

Installation

npm install @ravisavaj/angular-dynamic-form

Quick Start

1. Import the Module

import { DynamicFormModule } from '@ravisavaj/angular-dynamic-form';

@NgModule({
  imports: [
    DynamicFormModule,
    // ... other imports
  ]
})
export class AppModule { }

2. Use the Component

import { DynamicFormComponent, FormConfig } from '@ravisavaj/angular-dynamic-form';

@Component({
  selector: 'app-my-form',
  template: `
    <lib-dynamic-form
      [config]="formConfig"
      (formSubmit)="onSubmit($event)"
      (formCancel)="onCancel()">
    </lib-dynamic-form>
  `
})
export class MyFormComponent {
  formConfig: FormConfig = {
    fields: [
      {
        name: 'firstName',
        label: 'First Name',
        type: 'text',
        required: true,
        placeholder: 'Enter your first name'
      },
      {
        name: 'email',
        label: 'Email',
        type: 'email',
        required: true,
        placeholder: 'Enter your email'
      }
    ],
    submitButtonText: 'Submit',
    showSubmitButton: true
  };

  onSubmit(data: any) {
    console.log('Form submitted:', data);
  }

  onCancel() {
    console.log('Form cancelled');
  }
}

Field Types

Text Input

{
  name: 'firstName',
  label: 'First Name',
  type: 'text',
  required: true,
  placeholder: 'Enter your first name',
  minLength: 2,
  maxLength: 50
}

Email Input

{
  name: 'email',
  label: 'Email Address',
  type: 'email',
  required: true,
  placeholder: 'Enter your email'
}

Number Input

{
  name: 'age',
  label: 'Age',
  type: 'number',
  min: 18,
  max: 100,
  placeholder: 'Enter your age'
}

Textarea

{
  name: 'bio',
  label: 'Biography',
  type: 'textarea',
  rows: 4,
  placeholder: 'Tell us about yourself'
}

Select

{
  name: 'country',
  label: 'Country',
  type: 'select',
  options: [
    { value: 'us', label: 'United States' },
    { value: 'uk', label: 'United Kingdom' },
    { value: 'ca', label: 'Canada' }
  ]
}

Multiselect

{
  name: 'skills',
  label: 'Skills',
  type: 'multiselect',
  options: [
    { value: 'angular', label: 'Angular' },
    { value: 'react', label: 'React' },
    { value: 'vue', label: 'Vue.js' }
  ]
}

Checkbox

{
  name: 'newsletter',
  label: 'Subscribe to newsletter',
  type: 'checkbox'
}

Date Input

{
  name: 'birthDate',
  label: 'Date of Birth',
  type: 'date'
}

Layout Options

Vertical Layout (Default)

{
  layout: 'vertical',
  fields: [...]
}

Horizontal Layout

{
  layout: 'horizontal',
  fields: [...]
}

Grid Layout

{
  layout: 'grid',
  columns: 12,
  fields: [
    {
      name: 'firstName',
      gridColumnSpan: 6  // Takes 6 columns
    },
    {
      name: 'lastName',
      gridColumnSpan: 6  // Takes 6 columns
    }
  ]
}

API Integration

Load select options from APIs using the DynamicOptionsService:

import { DynamicOptionsService } from '@ravisavaj/angular-dynamic-form';

@Component({...})
export class MyComponent {
  constructor(private optionsService: DynamicOptionsService) {}

  loadCountries() {
    this.optionsService.loadOptions({
      endpoint: '/api/countries',
      valueField: 'id',
      labelField: 'name'
    }).subscribe(options => {
      // Use options in your form config
    });
  }
}

Validation

Built-in Validators

  • required: Field is required
  • minLength: Minimum character length
  • maxLength: Maximum character length
  • min: Minimum value (for numbers)
  • max: Maximum value (for numbers)
  • pattern: Regular expression pattern
  • email: Email format validation

Custom Validation

{
  name: 'username',
  label: 'Username',
  type: 'text',
  customValidation: (control) => {
    if (control.value && control.value.length < 3) {
      return { minLength: { requiredLength: 3 } };
    }
    return null;
  }
}

Custom Error Messages

{
  name: 'email',
  label: 'Email',
  type: 'email',
  validationMessages: {
    required: 'Email is required',
    email: 'Please enter a valid email address'
  }
}

Events

The component emits several events:

  • formSubmit: When the form is submitted (with form data)
  • formCancel: When the cancel button is clicked
  • formChange: When any field value changes
  • fieldChange: When a specific field changes
  • validationError: When validation errors occur

Styling

The component uses CSS classes that you can customize:

.dynamic-form {
  /* Main form container */
}

.form-group {
  /* Individual field container */
}

.form-label {
  /* Field labels */
}

.form-control {
  /* Input fields */
}

.error-message {
  /* Validation error messages */
}

.btn-primary {
  /* Submit button */
}

.btn-secondary {
  /* Cancel button */
}

Examples

See the examples folder for complete working examples:

import { basicFormConfig } from '@ravisavaj/angular-dynamic-form';

// Use the basic form configuration
formConfig = basicFormConfig;

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Support