【问题标题】:$location not working in AngularJS using d3.js$location 在使用 d3.js 的 AngularJS 中不起作用
【发布时间】:2012-10-14 19:57:02
【问题描述】:

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

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

var parentCtrl = function($scope,$location){ $scope.makeBSC = 函数(){ var changePath = 函数(el){ 控制台.log($location.path()); $location.path(el) } 变量宽度 = 405, 高度 = 420, 颜色 = d3.scale.category20c(); var vis = d3.select("#bscChart").append("svg") .attr("宽度", 高度) .attr("高度", 宽度); var partition = d3.layout.partition() .size([宽度,高度]) .value(function(d) { return d.size; }); var json = 数据; vis.data([json]).selectAll("rect") .data(partition.nodes) .enter().append("矩形") .attr("y", function(d) { return d.x; }) .attr("x", function(d) { return d.y; }) .attr("身高", function(d) { return d.dx; }) .attr("宽度", function(d) { return d.dy; }) .attr("类",函数(d){ 如果(d.isSel)返回“rectBlue” 返回“矩形灰色” }).on("点击", function(d){ 改变路径(d.goTo); }); } }

【问题讨论】:

  • 嗨,我想你会在这个问题中找到你的问题的答案:AngularJS $location not changing the path
  • 啊!太感谢了!我试过申请,但我的语法不正确。非常感激!您想将此添加为回复,以便我将其标记为正确吗?

标签: javascript angularjs d3.js


【解决方案1】:

强迫症不会让我把这个问题“开放”。所以,正如 groner 指出的那样......嗨,我想你会在这个问题中找到你问题的答案:AngularJS $location not changing the path

还有一点价值广告。检查这些包装 d3 http://www.fullscale.co/dangle/

的指令

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多