我想在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的链接,以查看完整的示例
答案 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) // <==
};