当数组是对象的 属性 时如何将数组绑定到列表
How to bind array to list when array is property of the object
我有以下对象:
parent = {
prop1: "asd",
prop2: "zxc",
arr: [
{
title: "qwe",
attr: {attr1: "987", attr2: "dfg"}
},
{
title: "poi",
attr: {attr1: "345", attr2: "jkl"}
}
]
}
我想将其绑定到以下列表:
<List id="list" items="{parent>/arr}" headerText="Example">
<items>
<ObjectListItem title="{parent>arr/title}" type="Active" press="onListItemPress">
<attributes>
<ObjectAttribute text="{parent>arr/attr/attr2}" />
</attributes>
</ObjectListItem>
</items>
</List>
我无法让它工作。
在此列表中显示 title 和 attr2 属性的正确方法是什么?
试试这个语法视图绑定,它是有效的:
<List id="list" items="{parent>/arr}" headerText="Example">
<items>
<ObjectListItem title="{parent>title}" type="Active" press="onListItemPress">
<attributes>
<ObjectAttribute text="{parent>attr/attr2}" />
</attributes>
</ObjectListItem>
</items>
</List>
我有以下对象:
parent = {
prop1: "asd",
prop2: "zxc",
arr: [
{
title: "qwe",
attr: {attr1: "987", attr2: "dfg"}
},
{
title: "poi",
attr: {attr1: "345", attr2: "jkl"}
}
]
}
我想将其绑定到以下列表:
<List id="list" items="{parent>/arr}" headerText="Example">
<items>
<ObjectListItem title="{parent>arr/title}" type="Active" press="onListItemPress">
<attributes>
<ObjectAttribute text="{parent>arr/attr/attr2}" />
</attributes>
</ObjectListItem>
</items>
</List>
我无法让它工作。
在此列表中显示 title 和 attr2 属性的正确方法是什么?
试试这个语法视图绑定,它是有效的:
<List id="list" items="{parent>/arr}" headerText="Example">
<items>
<ObjectListItem title="{parent>title}" type="Active" press="onListItemPress">
<attributes>
<ObjectAttribute text="{parent>attr/attr2}" />
</attributes>
</ObjectListItem>
</items>
</List>