Mustache js - 获取json数组名称

时间:2016-01-03 12:55:18

标签: mustache

[{
    "ASIN": "B009NPAORC",
    "itemTitle": "Goliton with Andriod"
}]

在上面的代码中,我希望在ASIN模板中获得mustache{{}}{{}}中的内容是什么?

1 个答案:

答案 0 :(得分:1)

将您的价值赋予变量:

    private void txtQryName_TextChanged(object sender, EventArgs e)
    {
        List<string> fullName = _customerBll.NameSuggestor(txtQryName.Text);
        AutoCompleteStringCollection source = new AutoCompleteStringCollection();
        source.AddRange(fullName.ToArray());
        txtQryName.AutoCompleteMode = AutoCompleteMode.Suggest;
        txtQryName.AutoCompleteSource = AutoCompleteSource.CustomSource;
        txtQryName.AutoCompleteCustomSource = source;
    }

我们可以使用以下方法在模板中拉出单个数组元素:

var objs = [ { "ASIN": "B009NPAORC", "itemTitle": "Goliton with Andriod" } ];

或者使用:

循环数组
<li>{{objs.0.ASIN}}: {{objs.0.itemTitle}}</li>