【发布时间】:2020-11-01 14:04:35
【问题描述】:
我有一个从以下 ts 函数加载到我的页面上的项目列表,如下所示
export class Test extends Component {
public Stores: Array<StoresModel> = [];
public Items: Array<ItemsModel> = [];
async GetStores() {
let result = await //gets result from db;
this.Stores= result.items;
}
}
然后我将上面的结果绑定到html中如下
<md-collection>
<md-collection-item repeat.for="s of Stores" class="accent-text" >
<md-checkbox></md-checkbox> //how do i check this if an item is present for the given store
${s.title}
</md-collection-item>
</md-collection>
这给了我如下的商店列表
Store1
Store2
Store3
this.stores 的输出如下所示
[{storeId:"11111",title:"Store1"}]
[{storeId:"00000",title:"Store2"}]
[{storeId:"12345",title:"Store3"}]
the above works fine.
我有另一个功能可以从商店中获取所有商品 如下
async items() {
let Items= await //get items;
this.items= Items.items;
}
this.items 结果看起来像这样
[{storeId:"11111",title:"Shoes",id:"df12365"}]
[{storeId:"12345",title:"Clothes",id:"er45896"}]
现在我想在 html 页面中添加一个复选框,问题是如何检查包含项目的商店列表的复选框?
应该是这样的
[Checked] Stores1
[unchecked] stores2
[checked] stores3
我不确定如何将 this.stores 中的 StoreID 绑定到 this.items 的 storeID 以选中复选框
【问题讨论】:
标签: javascript typescript angular-material materialize aurelia