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

How to hide an edge of vis.js using angularjs

我想在 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 的 link 以查看完整示例

将边传递给 $scope.data 的问题不是 vis.DataSet:

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

==>

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

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