从Angular.js中的Array对象创建二叉树

时间:2019-02-28 09:06:45

标签: arrays angularjs

我有一个数组对象,显示为带有输入控件和值的行。此值根据对象值状态为true或false显示,如下面的示例链接所示。一旦在选择/取消选中复选框的情况下基于数组值生成了表,就应进行二进制选择,并且需要将其更新为新数组,如提到的“输出应为here”工作样例。这可以实现吗?方式吗?

 Actual scenario is the following, needs to convert binary tree based on "show"  true value.

{ Row: "1",
      RowValues: [ 
       {td:"1", show: true},
       {td:"2", show: true},
       {td:"3", show: true},
       {td:"4", show: true},
       {td:"5", show: true}
       ]
     },


    { Row: "2",
      RowValues: [ 
       {td:"6", show: false},
       {td:"7", show: false},
       {td:"8", show: false},
       {td:"9", show: true},
       {td:"10", show: false}
       ]
     },

     { Row: "3",
      RowValues: [ 
       {td:"11", show: false},
       {td:"12", show: false},
       {td:"13", show: true},
       {td:"14", show: true}
       ]
     },

      { Row: "4",
      RowValues: [ 
       {td:"15", show: false},
       {td:"16", show: false},
       {td:"17", show: false},
       {td:"18", show: true}
       ]
     }

    ]


Scenario is 
    1   2   3   4   5
                9   
            13  14
                18

while selecting the node 18
**output should be** [1,2,13,18]

Scenario is 
    1   2   3   4   5
                9   
            13  14
                18

 while selecting the node 3
  **output should be** [1,2,3,4, 5,9]

0 个答案:

没有答案