In my pagination component, here is my code below:
<p>Showing {{(page-1) * pageSize}} to {{ Math.min((page-1) * pageSize + pageSize,tasks.length)}} of {{tasks.length}}</p>.
But it did not works. Can anybody tell what problem it has?
In your component, you could add math = Math;
, then in your html, change it to
<p>Showing {{(page-1) * pageSize}} to {{ math.min((page-1) * pageSize + pageSize, tasks.length)}} of {{tasks.length}}</p>.
This creates a local copy of Math
without needing to create extra functions and getters
Check the original answer of Günter Zöchbauer
In short: It is not possible to access global variables from within the template files.
You have to at least create a getter that returns global variable.
In your typescript file create a getter called Math
get Math() {
return Math;
}
BUT I would either rename it to math
or create a helper methods in my typescript file
min
andmax
functions. or you could try to instantiateMath
as a local variable?