I have the following Angular 7 Typescript class:
export class Paging {
itemCount: number;
pageCount: number;
pageNumber: number;
pageSize: number;
constructor(pageNumber: number, pageSize: number, itemCount: number) {
this.itemCount = itemCount;
this.pageCount = itemCount > 0 ? (number)Math.ceil(itemCount / pageSize) : 0;
this.pageNumber = pageNumber;
this.pageSize = pageSize;
}
}
I have 2 problems:
1. How to import Math functions (at the moment I am getting an error)?
2. How to convert the result of the calculation Math.ceil(itemCount / pageSize) to an integer?
(number)bit and you should be fine. Typescript doesn't have an integer type, only number, butMath.ceilwill certainly return an integer in the mathematical sense