如何使用ng-click指令获取treeview angularjs中的选定值?

时间:2015-07-09 21:38:46

标签: javascript angularjs jstree

这是我的数据,分配给 $ scope.tree

            var data = [
            {
                "name": "vashi",
                id: "vashi",
                "children": [{
                    "name": "a",
                    id: "S1vashi",
                    "children": [{
                        "name": "bayQ",
                        "id": "S1T1vashi",
                        "children": ["a", "b", "c"]
                    }, {
                        "name": "bayQ1",
                        "id": "S1T2vashi",
                        "children": [{
                            "name": "a"
                        }]
                    }]
                }, {
                    "name": "b",
                    id: "S1vashi",
                    "children": [{
                        "name": "bayQ",
                        "id": "S1T1vashi",
                        "children": ["a", "b", "c"]
                    }, {
                        "name": "bayQ1",
                        "id": "S1T2vashi",
                        "children": ["a", "b", "c"]
                    }]
                }]
            },

            {
                "name": "andheri",
                id: "vashi",
                "children": [{
                    "name": "a",
                    id: "S1vashi",
                    "children": [{
                        "name": "bayQ",
                        "id": "S1T1vashi",
                        "children": ["a", "b", "c"]
                    }, {
                        "name": "bayQ1",
                        "id": "S1T2vashi",
                        "children": ["a", "b", "c"]
                    }]
                }, {
                    "name": "b",
                    id: "S1vashi",
                    "children": [{
                        "name": "bayQ",
                        "id": "S1T1vashi",
                        "children": ["a", "b", "c"]
                    }, {
                        "name": "bayQ1",
                        "id": "S1T2vashi",
                        "children": ["a", "b", "c"]
                    }]
                }]
            },
 ]

Html部分: -

    <div data-angular-treeview="false" data-tree-model="tree" data-node-id="id" data-node-label="name" data-node-children="children" data-tree-id="tree" data-ng-click="selectNode(currentNode.name)">

点击方法 $ scope.selectNode = function(val){console.log(val); }

我想在不同的城市选择多个孩子。当我选择孩子时,它的安慰是不确定的。

0 个答案:

没有答案