Reputation: 3384
I am using PrimeNg datatable with editable option true. I am getting following error:
Error:
ERROR in Error at D:/Project/ui/src/app/pages/admin/components/dashboard/dashboard.component.html(38,31): ("lumn.isSortab
le" [style]="column.columnStyle?column.columnStyle:{}">
<template [ERROR ->]let-col let-row="rowData" pTemplate="editor">
<textarea *ngIf="column.isEditab")
Error at D:/Project/ui/src/app/pages/admin/components/dashboard/dashboard.component.html(38,39): ("ortable" [style]="colu
mn.columnStyle?column.columnStyle:{}">
<template let-col [ERROR ->]let-row="rowData" pTemplate="editor">
<textarea *ngIf="column.isEditableAsText")
DataTable HTML:
<p-dataTable *ngIf="showTable()" [value]="tableConfig.data" [dataKey]="'id'" [rowStyleClass]="highLightUnsavedRow" [lazy]="true" [rows]="10" [paginator]="true" [responsive]="true" [totalRecords]="getTotalRecords()" (onLazyLoad)="onRowEvent($event)" [(selection)]="selectedRows"
(onRowSelect)="onRowSelect($event)" (onRowUnselect)="onRowUnselect($event)" [editable]="true" (onHeaderCheckboxToggle)="onHeaderCheckboxToggle($event)" (selectionChange)="onSelectionChange($event)">
<p-header>Header</p-header>
<p-column *ngIf="tableConfig.isMultiSelect" [style]="tableConfig.multiSelectColStyle?tableConfig.multiSelectColStyle:{'width':'38px'}" selectionMode="multiple"></p-column>
<p-column *ngFor="let column of tableConfig.columns" field="{{column.fieldName}}" header="{{column.columnTitle?column.columnTitle:column.fieldName}}" [filter]="column.isFilterable" [editable]="column.isEditable" [sortable]="column.isSortable" [style]="column.columnStyle?column.columnStyle:{}">
<template let-col let-row="rowData" pTemplate="editor">
<textarea *ngIf="column.isEditableAsText" class="edit-field" [(ngModel)]="row[col.field]" (change)="onTableEditTextBoxChange(row,col.field,row[col.field])"></textarea>
<p-dropdown *ngIf="column.isEditableAsDropDown" class="edit-field" autoWidth="false" [style]="column.editFieldStyle?column.editFieldStyle:{}" [(ngModel)]="row[col.field]" [options]="column.editDropDownOptions"></p-dropdown>
</template>
</p-column>
</p-dataTable>
The problem is with the attributes let-col and let-row="rowData" of following tag:
<template let-col let-row="rowData" pTemplate="editor">
If I remove these two attributes, then the build issue disappears but the table renders with 0 rows.
Upvotes: 1
Views: 1843
Reputation: 41571
ng-template
has to be used in Angular 5
<ng-template let-col let-row="rowData" pTemplate="editor">
It is now an error as it was deprecated in angular 4.x
You can still use <template>
by setting the enableLegacyTemplate
flag in the compliler options to true
which can be configured as
In the main.ts
const compilerOptions: CompilerOptions = {
enableLegacyTemplate: true
};
Use the value in the module as
platformBrowserDynamic().bootstrapModule(AppModule,compilerOptions)
Upvotes: 1