我正在尝试执行表行,并且我收到一条错误,指出属性'errors'未定义或为null。 Name.errors正在爆炸。关于我所缺少的任何想法。请参阅下面的代码。从Angular 2 table row control validation
得到了想法由于
<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>