首页 > 解决方案 > 从 Angularjs 中的 Array 对象创建二叉树

问题描述

我有一个数组对象,它显示为带有输入控件和值的行。此值根据对象值状态 true 或 false 显示,如下面的示例链接所示。一旦根据数组值生成表,同时选择/取消选择复选框,二进制选择应该发生,并且需要更新到新数组中,如帖子“输出应该是。这里是工作样本。这是可以实现的智能方式吗?

 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]

标签: arraysangularjs

解决方案


推荐阅读