开发者

How to calculate an expression in jQuery templates

I have data from an external JSON source that I want to display using jQUery templates. There are 2 integer variables. I need t开发者_高级运维o divide one by another inside my jQuery Templates template string. Now template string looks like this:

templateNumbers="${a}, ${b}"

I want not just to show these two numbers, but show a result of a dividing one by another.

JSON looks like this one:

[
    {
        a: 5,
        b: 1,
    },
    {
        a: 7,
        b: 2,
    }

]

I tried to use "${a/b}" but it doesn't work, may be because I have an array and may be I should play with $item? How can I do this? Thanks!


${a/b}

According to this intro page, you can have any expression in ${}


Make the division before and add another variable to send to the template with the result.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜