Installation
This guide walks you through installing Mat Dynamic Form and setting up all required dependencies in your Angular project.Prerequisites
Angular Version
Mat Dynamic Form supports Angular versions 11.x through 16.x:package.json
If you’re starting a new project, we recommend using Angular 15 or 16 for the best compatibility and features.
Angular Material
Mat Dynamic Form requires Angular Material to be installed and configured in your project. If you haven’t already set up Angular Material, install it first:- Choose a theme - Select any Material theme (Indigo/Pink, Purple/Green, etc.)
- Set up typography - Choose ‘Yes’ for Material typography
- Enable animations - Choose ‘Yes’ to include Angular animations
Peer Dependencies
The following packages are required as peer dependencies:@angular/animations(version 11.0.0 to 16.x.x)@angular/cdk(version 11.0.0 to 16.x.x)@angular/common(version 11.0.0 to 16.x.x)@angular/material(version 11.0.0 to 16.x.x)
Install Mat Dynamic Form
Once prerequisites are met, install the Mat Dynamic Form package:Module Setup
After installation, import and configure theMatDynamicFormModule in your Angular module.
App Module (Standalone Modules)
If you’re using traditional NgModules, addMatDynamicFormModule to your AppModule:
app.module.ts
Feature Module
If you’re organizing your application into feature modules, importMatDynamicFormModule in each feature module that uses dynamic forms:
feature.module.ts
MatDynamicFormModule can be imported in multiple modules - there’s no need to create a shared module for it.Standalone Components (Angular 14+)
If you’re using Angular’s standalone components feature, importMatDynamicFormModule directly in your component:
user-form.component.ts
Verify Installation
To verify that Mat Dynamic Form is installed correctly, create a simple test component:If you see a Material Design form with a title “Test Form” and one input field labeled “Test Field”, your installation is successful!
Troubleshooting
Module not found error
Module not found error
If you see
Cannot find module 'mat-dynamic-form', try:- Delete
node_modulesandpackage-lock.json - Run
npm installagain - Restart your IDE/development server
Peer dependency warnings
Peer dependency warnings
If you see warnings about peer dependencies, ensure your Angular version is between 11.x and 16.x:If your Angular version is incompatible, you may need to upgrade or downgrade:
Angular Material not configured
Angular Material not configured
If you see errors about missing Material components, Angular Material may not be properly configured:
- Ensure
@angular/materialis installed - Check that
BrowserAnimationsModuleis imported in your root module - Verify a Material theme is included in
styles.scss:
styles.scss
Bootstrap conflicts
Bootstrap conflicts
Mat Dynamic Form includes Bootstrap 4.6.0 as a dependency for grid layout. If you’re already using Bootstrap in your project, you may see style conflicts.To resolve this:
- Ensure only one Bootstrap version is loaded
- Check your
angular.jsonstyles array - Consider using Angular Material’s layout system instead
Next Steps
Now that Mat Dynamic Form is installed and configured, you’re ready to build your first dynamic form!Quick Start
Follow our step-by-step guide to create your first dynamic form
Core Concepts
Learn about FormStructure, Nodes, and Actions
