I have this code:
<pre>totalItems: {{vm.pagination.totalItems}}</pre>
<pre>items-per-page: {{vm.pagination.itemsPerPage}}</pre>
<pre>Total: Math.ceil({{vm.pagination.totalItems / vm.pagination.itemsPerPage}})</pre>
Output:
I'm using Math.ceil()
so the answer should be 11
but I'm not getting the correct answer as below:
How can I calculate angular value in braces? Please help and thanks in advance.
The best way is to create a scoped function:
<pre>Total: {{calculateTotal(vm.pagination.totalItems, vm.pagination.itemsPerPage)}}</pre>
Then add the function to the scope:
$scope.calculateTotal = function(totalItems, itemsPerPage) {
return Math.ceil(totalItems/itemsPerPage);
};