簡體   English   中英

如何在angularjs中使用json檢索基於數據的復選框選擇

[英]How to retrieve data based checkbox selection using json in angularjs

如何基於angularjs中的兩個json數組對象過濾復選框,此處的comp1和comp2相同。 如何將這兩個json對象推入一個數組中。

var comp1=
[
  {
    "ID": "GROUP",
    "Name": "client ",
    "ListItemID": "GROUP",
    "ListItemUniqueId": "00000000-0000-0000-0000-000000000000",
    "isSelected": true
  },
  {
    "ID": "co1",
    "Name": "comp1",
    "ListItemID": "3",
    "ListItemUniqueId": "00000000-0000-0000-0000-000000000000",
    "isSelected": true
  }];
var comp2=[
  {
    "Access": null,
    "AuditFile": null,
    "CurrentItem": null,
    "DAPSortOrder": 1,
    "DocName": null,
    "DocTitle": null,
    "DocUrl": null,
    "EnableComponent": false,
    "Id": 1,
    "ImageUrl": null,
    "PeriodName": "Planning",
    "RelatesTo": co1,
    "created": null,
    "type": null
  }];

使用lodash union()和filter()函數。

https://lodash.com/docs/4.16.6#union

https://lodash.com/docs/4.16.6#filter

var newArray = filter( join(comp1, comp2), function (item) {
     return item.isSelected || item.PeriodName; // any condition you need
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM