【发布时间】:2014-12-24 10:13:19
【问题描述】:
我正在使用自定义指令来刷新我的页面。我已经用 D3 编写了我的 UI。它是一个由节点和链接组成的简单图。
这就是我想要做的。 当我点击图的特定节点时,它会展开到它的子图等等。
以下是控制器
*vrmUI.controller('CompleteViewController', function($scope,$location, $rootScope, $route) {
// Assigning data
// onDeviceClick is called when node of graph is clicked.
$scope.onDeviceClick = function(item){
$rootScope.pageContextObject = $route.current.data;
$scope.clickedItem=item;
$scope.completeObject =//JSON Data
$scope.loadExpandedView=true;
$scope.showExpandedView=true;
};*
});
对应的html是
<div class="content-panel clearfix">
<div id="topoheader" style="font:12px sans-serif"></div>
// expandedView directive should get called when ever control goes inside onDeviceClick.
<expanded-view ng-show="showExpandedView"
ng-if="loadExpandedView" clicked-rack="clickedItem" network-data="completeObject"
device-click="onDeviceClick(item)"></expanded-views>
</div>
</div>
点击图表节点时调用设备点击。 指令是 *
vrmUI.directive('expandedView',function(){
function link(scope,el,attr){
// Processing when clicked
}
return{
restrict : 'E',
link: link,
scope : {
clickedItem : '=',
onDeviceClick : '&deviceClick'
}
};
});
*
问题:
当我单击一次它可以完美运行,但是当我单击图形的其他节点时,我可以看到控件进入 $scope.onDeviceClick = function(item){ 但我的指令没有像第一种情况那样被调用。无论如何我可以做到这一点吗?如果您需要更多详细信息或问题不清楚,请告诉我。
谢谢
【问题讨论】:
标签: javascript jquery angularjs node.js angularjs-directive