app.component.html 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <div class="central-col content-container mb-4">
  2. <div class="clr-row">
  3. <div class="clr-col-12 pt-4 pb-2">
  4. <h1>NgDynaform: Clarity Edition</h1>
  5. <p>
  6. <b>Dynamic Form Layout Module</b><br>
  7. Load different tests by appending a query param to the URL <b>?test=N</b> (where N is a number between 1 and 16).<br>
  8. NOTE: Model set to update on change, but this can be set to blur or submit for less re-rendering.
  9. </p>
  10. <br>
  11. </div>
  12. </div>
  13. <app-dynaform [formGroup]="form" [meta]="meta" [template]="tref" (call)="handleCallback($event)" debug="1"></app-dynaform>
  14. <!-- Uncomment to test access to deeply-nested FormGroups using formGroupName -->
  15. <!--
  16. <form [formGroup]="form">
  17. <span formGroupName="dynaformtest">
  18. <span formGroupName="d">
  19. <app-dynaform formGroupName="g" [meta]="meta" [template]="tref"></app-dynaform>
  20. </span>
  21. </span>
  22. </form>
  23. -->
  24. <div class="clr-row">
  25. <div class="clr-col-12 pt-4 pb-4">
  26. <json-formatter [data]="form.value" open="4"></json-formatter>
  27. </div>
  28. </div>
  29. </div>
  30. <ng-template #testTemplate_NOTWORKING let-control="control" let-meta="meta">
  31. <div class="form-group clr-row" *ngIf="meta.type !== 'Container'; else recursiveDynaform" [ngClass]="getRowClass(meta.type)">
  32. <label class="clr-col-sm-4" [for]="meta.name" style="color: purple">{{ meta.label }}</label>
  33. <div class="clr-col-sm-8">
  34. <ng-container dynafield [control]="control" [meta]="meta" (call)="handleCallback($event)"></ng-container>
  35. </div>
  36. </div>
  37. <ng-template #recursiveDynaform>
  38. <div class="clr-row pt-3">
  39. <h3 class="clr-col-sm-12" [ngClass]="'h-dyna-' + (path.length + 2)">{{ meta.label }}</h3>
  40. </div>
  41. <app-dynaform [formGroup]="control" [meta]="meta.meta" [template]="template" (call)="handleCallback($event)"></app-dynaform>
  42. </ng-template>
  43. </ng-template>