0

I'm try to do table row and I'm getting an error saying property 'errors' is undefined or null. Name.errors is blowing up. Any ideas on what I'm missing. See my code below. Got idea from Angular 2 table row control validation

Thanks

 <form >
  <p-dataTable [value]="data"  [editable]="true" [style]="{'whitespace': 'nowrap'}">
   <p-column field="Name" header="Name*" [sortable]="true" >
                <ng-template let-col let-rowVal="rowData" pTemplate="body" let-ri="rowIndex" >
                    <div style="padding-left:5px; padding-right:5px">
                        <span *ngIf="!rowVal.isEditing" class="editable-text">{{rowVal.Name}} </span>
                        <input type="text" *ngIf="rowVal.isEditing" [(ngModel)]="data[ri].Name" #Name="ngModel"  [value]="rowVal.Name"  name="Name{{ri}}" [pattern]="validName" required />
                        <div *ngIf="Name.errors != null && Name.errors?.pattern && rowVal.isEditing"><span style='color:#ff3a20'>Required</span></div>
                    </div>
                </ng-template>
            </p-column>
    </p-dataTable>
        </form>   

0 Answers0