[英]How to get multiple selected checkbox item from multiple checkbox list in angular
我在这里有最少的复制https://stackblitz.com/edit/angular-uwfsyv?file=app%2Fapp.component.html ,我有 2 个数组, checkboxesDataList
和checkboxesDataList2
我成功地从checkboxesDataList
获得了选中的标签,但这只是为了一个例子。
但是我想在我的项目中得到的类似于这里的checkboxesDataList2
我有对象question
而checkboxesDataList
没有,所以这个功能
fetchSelectedItems() {
this.selectedItemsList = this.checkboxesDataList.filter((value, index) => {
return value.checked;
});
}
如果我将this.checkboxesDataList
更改为this.checkboxesDataList2
将不会立即工作我怎样才能让它工作?
你想拥有这样的功能吗?
getDataChecked()
{
return this.checkboxesDataList2.question
.map(x=>x.options.filter(o=>o.checked))
.reduce((acc, value)=>[...acc,...value])
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.