如何使用angularjs隐藏vis.js的边缘

时间:2016-04-26 14:53:44

标签: angularjs vis.js

我想在angularjs控制器中隐藏节点及其所有依赖边。我使用angular-vis.js。我的代码只能隐藏节点,但不能隐藏边缘。

$scope.hideSelection = function() 
{ 
    $scope.data.nodes.update([{id: $scope.selectedNode.toString(), hidden: true}]); // this part is working fine
    $scope.hiddenNodes.push($scope.selectedNode);

    if ($scope.selectedEdges.length > 0){
       $scope.selectedEdges.forEach(function(edgeId){
           $scope.data.edges.update([{id: edgeId.toString(), hidden: true}]); // When it comes here it not doing the update as it did on nodes
           $scope.hiddenEdges.push(edgeId);
       });
    } 
}

以下是我plunker的链接,以查看完整的示例

1 个答案:

答案 0 :(得分:0)

将边缘传递给$scope.data而不是vis.DataSet:

的问题
$scope.data = 
{
  nodes: new vis.DataSet(nodes),
  edges: edges //  <==
};

==&GT;

 $scope.data = 
{
  nodes: new vis.DataSet(nodes),
  edges: new vis.DataSet(edges) // <==
};

[http://plnkr.co/edit/1H1RBZr9KUPrVhAqT6fX]

相关问题