开发者

How can I access some json value dynamicailly with jquery templates

开发者 https://www.devze.com 2023-03-30 08:11 出处:网络
I have the following json and suppose that I can\'t modify it: { \"structure\": [ {\"property\": \"propA\"},

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

精彩评论

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