Angular 角度4+;启动:将HTML内容从一个组件传递到另一个组件
我想在多个位置向Priming datatable(p-datatable)添加一些服务器端分页函数,因此我声明了一个新组件“pagin datatable.component”,其中包含我需要的函数和行为 因此,pagin datatable.component.html(模板)附带:Angular 角度4+;启动:将HTML内容从一个组件传递到另一个组件,angular,datatable,primeng,primeng-datatable,angular2-ngcontent,Angular,Datatable,Primeng,Primeng Datatable,Angular2 Ngcontent,我想在多个位置向Priming datatable(p-datatable)添加一些服务器端分页函数,因此我声明了一个新组件“pagin datatable.component”,其中包含我需要的函数和行为 因此,pagin datatable.component.html(模板)附带: <p-dataTable [value]="value" resizableColumns="true" scrollable="true" scrollWidth="100%"
<p-dataTable [value]="value"
resizableColumns="true"
scrollable="true"
scrollWidth="100%"
[(rows)]="this.gridOptions.rows"
[paginator]="true"
[lazy]="true"
[totalRecords]="nbTotal"
(onFilter)="filtrage($event)"
(onPage)="pagination($event)"
(onSort)="tri($event)"
[rowsPerPageOptions]="rowsPerPageOptions" >
/* There should be the p-columns */
</p-dataTable>
/*应该有p列*/
我希望我的p列仍然在mymain.component.html中声明,比如:
<pagin-datatable [value]="partenaires" (pagin)="refresh($event)" [rowsPerPageOptions]="[5,10,20,40]">
<p-column sortable="true" [filter]="true" field="aField" header="A HEADER"></p-column>
/* And so it goes for every other p-columns */
</pagin-datatable>
/*其他p列也是如此*/
我的问题是:如何告诉我的pagin组件让p-datatable处理发送到组件标记中的内容
在回答以下问题后:
找到了这篇文章来解决素数问题:github.com/primefaces/priming/issues/1215。您可以像这样在pagin datatable.component.html中使用
<p-dataTable [value]="value"
resizableColumns="true"
scrollable="true"
scrollWidth="100%"
[(rows)]="this.gridOptions.rows"
[paginator]="true"
[lazy]="true"
[totalRecords]="nbTotal"
(onFilter)="filtrage($event)"
(onPage)="pagination($event)"
(onSort)="tri($event)"
[rowsPerPageOptions]="rowsPerPageOptions" >
/* There should be the p-columns */
<ng-content></ng-content>
</p-dataTable>
/*应该有p列*/
在main.component.html中,您可以根据需要在pagin datatable中扭曲列。完全忘记了Angular的这个主要功能。。。谢谢但是,生命周期阻止表恢复p列。找到此文章(通过键入ng content+primeng)以修复此问题:。很好用!