JSPM

@covalent/dynamic-forms

1.0.0-beta.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 470
  • Score
    100M100P100Q98972F
  • License MIT

Teradata UI Platform Dynamic Forms Module

Package Exports

  • @covalent/dynamic-forms

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@covalent/dynamic-forms) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

td-dynamic-forms

API Summary

Properties:

Name Type Description
elements? ITdDynamicElementConfig[] JS Object that will render the elements depending on its config. [name] property is required.
form get(): FormGroup Getter property for dynamic [FormGroup].
valid get(): boolean Getter property for [valid] of dynamic [FormGroup].
value get(): any Getter property for [value] of dynamic [FormGroup].
errors get(): {[name: string]: any} Getter property for [errors] of dynamic [FormGroup].
controls get(): {[key: string]: AbstractControl} Getter property for [controls] of dynamic [FormGroup].

Setup

Import the [CovalentDynamicFormsModule] using the forRoot() method in your NgModule:

import { CovalentDynamicFormsModule } from '@covalent/dynamic-forms';
@NgModule({
  imports: [
    CovalentDynamicFormsModule.forRoot(),
    ...
  ],
  ...
})
export class MyModule {}

Usage

td-dynamic-forms element generates a form dynamically

Pass an array of javascript objects that implement [ITdDynamicElementConfig] with the information to be rendered to the [elements] attribute.

export interface ITdDynamicElementConfig {
  label?: string;
  name: string;
  type: TdDynamicType | TdDynamicElement;
  required?: boolean;
  min?: any;
  max?: any;
  selections?: any[];
  default?: any;
}

Example for HTML usage:

<td-dynamic-forms [elements]="elements">
</td-dynamic-forms>
import { ITdDynamicElementConfig, TdDynamicElement, TdDynamicType } from '@covalent/dynamic-forms';
...
})
export class Demo {
  elements: ITdDynamicElementConfig[] = [{
    name: 'input',
    type: TdDynamicElement.Input,
    required: true,
  }, {
    name: 'slider',
    label: 'Label',
    type: TdDynamicElement.Slider,
    required: true,
  }, {
    name: 'boolean',
    type: TdDynamicType.Boolean,
    default: false,
  }, {
    name: 'select',
    type: TdDynamicElement.Select,
    required: true,
    selections: ['A','B','C']
    default: 'A',
  }];
}