This is my code bit of a heat-map in Kendo UI.
<div ng-repeat="h in row.hours" ng-style="h.styleStr"
data-value="{{params.compare ? h.percentChange : h.current[unit]}}"
data-time="{{$index}}">
{{params.compare ? h.percentChange : h.current[unit]}}
</div>
Its works perfectly fine. what the h.current[unit]
inside the div, does is, it displays the value (in decimal notation). Like this..
However I need to display the decimal values as integers. Like this...
And I have a intFormat
function that does just that. For eg:
intFormat(79.952)
will return 80
. So i'm trying to format the numbers inside the heatmap using the intFormat function. How to achieve this? I don't know if this is legal but I tried {{params.compare ? h.percentChange : intFormat(h.current[unit])}}
, but its not working. I'm using Angularjs 1X and KendoUI. Can I use function inside the double curly brace?
Interpolation refers to embedding expressions into marked up text. By default, interpolation uses the double curly braces {{ and }} as delimiters.
Using the double braces: The double curly braces can be used to displays the content from the model to the view component. Whatever is written inside double curly braces, will be displayed exactly at the place the expression is placed.
In languages like C curly braces ( {} ) are used to create program blocks used in flow control. In Python, curly braces are used to define a data structure called a dictionary (a key/value mapping), while white space indentation is used to define program blocks.
The double curly brackets are not HTML but scripting code. The term inside, interest, is a placeholder, sort of like the name and address in a form letter. The string {{interest}} will be replaced when the HTML template is converted into straight HTML that is sent over the network to the user.
Sure you can:
create a function like this
$scope.getDisplayValue = function(currentValue)
{
return intFormat(currentValue);
}
And then reference it like this in the html:
{{getDisplayValue(h.percentChange)}}
Please let me know if you have any questions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With