-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(dynamic-forms): dynamically add, edit, remove Form Controls durin…
…g runtime Refactored form controls to use FormArray API to add, edit, and remove controls. closes #624
- Loading branch information
jo186026
committed
Jul 25, 2017
1 parent
7f2815d
commit aba0a8b
Showing
8 changed files
with
514 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
<form [formGroup]="dynamicForm" novalidate> | ||
<div layout="row" | ||
layout-wrap | ||
layout-margin | ||
layout-align="start center"> | ||
<ng-template let-element ngFor [ngForOf]="elements"> | ||
<td-dynamic-element [formControlName]="element.name" | ||
[dynamicControl]="dynamicForm.controls[element.name]" | ||
[id]="element.name" | ||
[label]="element.label || element.name" | ||
[type]="element.type" | ||
[required]="element.required" | ||
[min]="element.min" | ||
[max]="element.max" | ||
[selections]="element.selections"> | ||
<div layout="row" | ||
layout-wrap | ||
layout-margin | ||
layout-align="start center" | ||
formArrayName="formArray"> | ||
<ng-template let-control ngFor [ngForOf]="dynamicForm.controls['formArray'].controls" let-i="index"> | ||
<td-dynamic-element | ||
[dynamicControl]="control" | ||
[elementName]="control.tdElementConfig.name" | ||
[id]="control.tdElementConfig.name" | ||
[label]="control.tdElementConfig.label || control.tdElementConfig.name" | ||
[type]="control.tdElementConfig.type" | ||
[required]="control.tdElementConfig.required" | ||
[min]="control.tdElementConfig.min" | ||
[max]="control.tdElementConfig.max" | ||
[selections]="control.tdElementConfig.selections"> | ||
</td-dynamic-element> | ||
</ng-template> | ||
</div> | ||
<ng-content></ng-content> | ||
</form> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.