I've done some searching around for a solution, but page breaks in an Angular 13 component will not break pages.
I am using a simple ng-template (extra fields removed for readability):
<ng-template #testTemplate let-allTheData>
<div *ngFor="let dataItem of allTheData" >
<div><b>ID:</b> {{ dataItem.id }}</div>
<div style="break-after:always;"> </div> <-- non-working page break
</div>
The template is setup as a ViewChild like this:
@ViewChild('testTemplate ') testTemplate !: TemplateRef<any>;
The data gets passed in and processed through a loop
data.forEach(x => {
theThing = {};
theThing.id = arrtId;
this.theData.push(theThing);
});
And the print dialog gets called with this line (using ngx-print):
this.printer.printAngular(this.testTemplate);
The data shows up fine on the print screen, but the page break in the template does not insert a page break - is the template interfering? I've also tried "break-after: page," "break-after: auto" and even "break-before: page," "break-before: auto" and "break-before: always." I also tried using the CSS media queries I've seen in a few searches and adding "!Important" to the inline CSS. Nothing has yet worked. Does anyone have any ideas? Thank you!