Skip to content

Schematics

Use Angular schematics to scaffold and register new formwork controls, groups, or blocks.

All three schematics (control, group, block) support the same options:

OptionTypeRequiredDefault (control/group/block)Description
—keystringYesRegistration key used in the Formwork configuration.
—namestringNokeyBase name for component and interface.
—projectstringNoworkspace default projectAngular project name where files are generated.
—pathstringNocurrent working directoryFolder path for generating files.
—interface-suffixstringNoControl / Group / BlockSuffix appended to the interface name.
—component-suffixstringNoControl / Group / BlockSuffix appended to the component class name.
—helperbooleanNotrueInclude helper files for view providers and host directives.
—helperPathstringNo[projectRoot]/src/app/shared/helperAbsolute path where helper files are generated if --helper is enabled. If the files cannot be found it will fallback to using the verbose syntax

Scaffold a control with all options

Command:

Terminal window
ng generate ngx-formwork:control --key rating --name StarRating --interface-suffix Props --component-suffix Widget

Artifacts generated:

ArtifactValue
interface filestar-rating-props.type.ts
interface nameStarRatingProps
component filestar-rating-widget.component.ts
component classStarRatingWidgetComponent
registration key'rating'

Run:

Terminal window
ng generate ngx-formwork:control --key <control-key> [--name <ComponentName>] [--project <project>] [--path <path>] [--interface-suffix <suffix>] [--component-suffix <suffix>]

This will:

  • Scaffold an interface <name><interfaceSuffix>.ts extending NgxFwControl.
  • Generate component files (<name><componentSuffix>.component.ts, .html, .scss, .spec.ts) wired with NgxfwControlDirective.
  • Register the new control in your Formwork configuration under componentRegistrations with the given key.

For implementation details and advanced usage, see the Controls Guide.

Run:

Terminal window
ng generate ngx-formwork:group --key <group-key> [--name <ComponentName>] [--project <project>] [--path <path>] [--interface-suffix <suffix>] [--component-suffix <suffix>]

This will:

  • Scaffold an interface <name><interfaceSuffix>.ts extending NgxFwFormGroup.
  • Generate component files (<name><componentSuffix>.component.ts, .html, .scss, .spec.ts) wired with NgxfwGroupDirective.
  • Register the new group in your Formwork configuration under componentRegistrations with the given key.

For implementation details and advanced usage, see the Groups Guide.

Run:

Terminal window
ng generate ngx-formwork:block --key <block-key> [--name <ComponentName>] [--project <project>] [--path <path>] [--interface-suffix <suffix>] [--component-suffix <suffix>]

This will:

  • Scaffold an interface <name><interfaceSuffix>.ts extending NgxFwBlock.
  • Generate component files (<name><componentSuffix>.component.ts, .html, .scss, .spec.ts) wired with NgxfwBlockDirective.
  • Register the new block in your Formwork configuration under componentRegistrations with the given key.

For implementation details and advanced usage, see the Blocks Guide.

Overriding Default Options in angular.json

Section titled “Overriding Default Options in angular.json”

You can set default values for any ngx-formwork schematic option in your angular.json. Add a schematics section under your project with the schematic name and desired defaults. For example:

{
"projects": {
"my-app": {
"schematics": {
"ngx-formwork:control": {
"helper": false,
"helperPath": "src/app/shared/helpers"
},
"ngx-formwork:group": {
"helper": true
},
"ngx-formwork:block": {
"helperPath": "src/app/core/formwork/helpers"
}
}
}
}
}