DataTable - Templating中自定义模板的时候报错:Template parse errors: 'ng-template' is not a known element:
解决:因为<ng-template>是angular4的标签,所以会报错,如果使用angular2,那么可以将标签替换为<template>这样就可以了,也就是 angular4->primeng4、angular2->primeng2
angular2示例代码:
<!-- 使用primeNG表格自动排序功能--> <p-dataTable [value]="cars"> <p-column field="operate" header="操作"> <template let-car="rowData" pTemplate="body"> <a><i class="fa fa-delete"></i>删除</a> <a [routerLink]="['../sns-question-answer-detial']" class="fa fa-editor">编辑</a> </template> </p-column> <p-column field="title" header="问答标题"></p-column> <p-column field="dec" header="问答描述"></p-column> <p-column field="from" header="来源" [sortable]="true"></p-column> <p-column field="pUser" header="提问人"></p-column> <p-column field="pDate" header="提问日期" [sortable]="true"></p-column> <p-column field="uDate" header="更新日期" [sortable]="true"></p-column> <p-column field="aNum" header="回答数" [sortable]="true"></p-column> <p-column field="lNum" header="关注数" [sortable]="true"></p-column> <p-column field="count" header="累计赞" [sortable]="true"></p-column> </p-dataTable>原文链接:https://www.f2er.com/angularjs/147324.html