Private/Angular/Component/Crud/New-NgCrudComponentHtmlToString.ps1

Function New-NgCrudComponentHtmlToString([WebCsprojInfo]$webCsprojInfo, [TableInfo]$tableInfo)
{
    [string]$result = @"
<div *ngIf="$($tableInfo.tableLowerCamel)">
  <h2>$($tableInfo.tablePretty)</h2>

  <form [formGroup]="$($tableInfo.tableLowerCamel)Form" (ngSubmit)="save()">
"@


    foreach ($columnInfo in $tableInfo.columnInfos)
    {
        $result = $result + @"
            <div class="form-group">
              <label for="name">{{formMetaData.$($columnInfo.columnLowerCamel).caption}}</label>
              <input type="text" id="$($columnInfo.columnLowerCamel)" class="form-control" formControlName="$($columnInfo.columnLowerCamel)" [ngStyle]="formMetaData.$($columnInfo.columnLowerCamel).style" [attr.maxlength]="formMetaData.$($columnInfo.columnLowerCamel).maxlength">
              <div *ngIf="formErrors.$($columnInfo.columnLowerCamel)" class="alert alert-danger">
                {{ formErrors.$($columnInfo.columnLowerCamel)}}
              </div>
            </div>
"@

    }

    $result = $result + @"
    <button type="submit" class="btn btn-default" [disabled]="!$($tableInfo.tableLowerCamel)Form.valid" >Save</button>
    <button class="btn btn-secondary" (click)="goBack()">Back</button>
    <button class="btn btn-danger" (click)="delete()">Delete</button>
  </form>
</div>
"@


    return $result 
}