Javascript $location在使用d3.js的AngularJS中不起作用

Javascript $location在使用d3.js的AngularJS中不起作用,javascript,angularjs,d3.js,Javascript,Angularjs,D3.js,这是我第一次面对这个问题,我不知道为什么。 我正在使用d3创建一个。 有一个单击事件正在触发并调用changePath()。我看到控制台日志,这意味着我确实有权访问$location.path,但当我尝试设置它时,什么都没有发生:没有新页面,没有错误页面,什么都没有 如果我不通过angular更改路径,我的路由器将无法维护我正在寻找的范围。 有什么线索吗 var parentCtrl = function($scope,$location){ $scope.makeBSC = function

这是我第一次面对这个问题,我不知道为什么。
我正在使用d3创建一个。
有一个单击事件正在触发并调用
changePath()
。我看到控制台日志,这意味着我确实有权访问
$location.path
,但当我尝试设置它时,什么都没有发生:没有新页面,没有错误页面,什么都没有

如果我不通过angular更改路径,我的路由器将无法维护我正在寻找的范围。
有什么线索吗

var parentCtrl = function($scope,$location){ $scope.makeBSC = function(){ var changePath = function(el){ console.log($location.path()); $location.path(el) } var width = 405, height = 420, color = d3.scale.category20c(); var vis = d3.select("#bscChart").append("svg") .attr("width", height) .attr("height", width); var partition = d3.layout.partition() .size([width, height]) .value(function(d) { return d.size; }); var json = data; vis.data([json]).selectAll("rect") .data(partition.nodes) .enter().append("rect") .attr("y", function(d) { return d.x; }) .attr("x", function(d) { return d.y; }) .attr("height", function(d) { return d.dx; }) .attr("width", function(d) { return d.dy; }) .attr("class",function(d){ if(d.isSel) return "rectBlue" return "rectGray" }).on("click", function(d){ changePath(d.goTo); }); } } var parentCtrl=函数($scope,$location){ $scope.makeBSC=函数(){ var changePath=功能(el){ log($location.path()); $location.path(el) } var宽度=405, 高度=420, 颜色=d3.scale.category20c(); var vis=d3.选择(#bscChart”).追加(“svg”) .attr(“宽度”,高度) .attr(“高度”,宽度); var partition=d3.layout.partition() .尺寸([宽度、高度]) .value(函数(d){返回d.size;}); var json=数据; vis.data([json]).selectAll(“rect”) .数据(分区.节点) .enter().append(“rect”) .attr(“y”,函数(d){返回d.x;}) .attr(“x”,函数(d){返回d.y;}) .attr(“高度”,函数(d){返回d.dx;}) .attr(“宽度”,函数(d){返回d.dy;}) .attr(“类”,函数(d){ 如果(d.isSel)返回“蓝色” 返回“灰色” }).打开(“单击”,功能(d){ 变更路径(d.goTo); }); } }
强迫症科不会让我把这个问题留作‘公开’的。所以,正如格罗纳指出的。。。嗨,我想你会在这个问题中找到你问题的答案:


另外,还有一点增值广告。检查一下包装d3的指令嗨,我想你会在这个问题中找到你问题的答案:啊!非常感谢你!我曾尝试应用,但语法不正确。非常感谢!您想将此添加为响应,以便我将其标记为正确?