Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
knockout.js和asp.net字典_Asp.net_Dictionary_Knockout.js - Fatal编程技术网

knockout.js和asp.net字典

knockout.js和asp.net字典,asp.net,dictionary,knockout.js,Asp.net,Dictionary,Knockout.js,我正在尝试访问下面转换为json的字典的密钥。value1是dictionary的值,但是如何获取键呢?JSON显示了一个细节对象,如果有意义的话,属性就是键。那么如何在jquery模板中呈现该属性中的键名呢 {{each(index, value) $data}} <div class="flaw"> <div class="Title" data-bind="click: app.viewModel.caseStudy.showFlawDet

我正在尝试访问下面转换为json的字典的密钥。value1是dictionary的值,但是如何获取键呢?JSON显示了一个细节对象,如果有意义的话,属性就是键。那么如何在jquery模板中呈现该属性中的键名呢

{{each(index, value) $data}}
        <div class="flaw">
        <div class="Title" data-bind="click: app.viewModel.caseStudy.showFlawDetails(index)"> ${value.Title} </div>
        <div class="Items">
        {{each(index1, value1) value.Details}}
             <div>${value.Details[index1]}: <input type="text" data-bind="value: value1" /></div>
        {{/each}}
        </div>
        </div>
        {{/each}}
{{每个(索引、值)$data}
${value.Title}
{{each(index1,value1)value.Details}
${value.Details[index1]}:
{{/每个}}
{{/每个}}

我使用了一个对象数组。对象[]

             public object[] Details { get; set; }

     Details = (from e in f.Elements()
                                                                        select new
                                                                        {
                                                                            Key = e.Name.ToString(),
                                                                            Value = GetValue(e)
                                                                        }).ToArray(),

        <script id="flawTemplate" type="text/html">
            {{each(index, value) $data}}
            <div class="flaw">
            <div class="Title" data-bind="click: app.viewModel.caseStudy.showFlawDetails(index)"> ${value.Title} </div>
            <div class="Items">
            {{each(index1, value1) value.Details}}
                 <div>${value1.Key}: <input type="text" data-bind="value: value1.Value" /></div>
        {{/each}}
        </div>
        </div>
        {{/each}}
    </script>
public object[]详细信息{get;set;}
详细信息=(来自f.Elements()中的e)
选择新的
{
Key=e.Name.ToString(),
Value=GetValue(e)
}).ToArray(),
{{each(索引、值)$data}
${value.Title}
{{each(index1,value1)value.Details}
${value1.Key}:
{{/每个}}
{{/每个}}