开发者

How can I access some json value dynamicailly with jquery templates

I have the following json and suppose that I can't modify it:

{
    "structure": [
        {"property": "propA"},
        {"property": "propB"}
    ],
    "data": {
        "propA": 7,
        "propB": "something"
    }
}

Now the template:

{{each structure}}
        <span>${data.开发者_运维问答$value.property}}</span>
{{/each}}

What I want to achieve is that where I do ${data.$value.property}} have the same result as if I do ${data.propA}

Issue: I don't know that "propA" exists whithin the "data" json. I have to access that part dinamically

thanks in advance!


Try this:

<span>${data[$value.property]}}</span>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜