javascript – $location不使用d3.js在AngularJS中工作

栏目: JavaScript · 发布时间: 6年前

内容简介:翻译自:https://stackoverflow.com/questions/13054944/location-not-working-in-angularjs-using-d3-js

这是我第一次面对这个问题而无法弄清楚原因.

我正在使用d3创建一个 icicle chart

.有一个点击事件正在触发并调用changePath().我看到控制台日志,这意味着我有权访问$location.path,但是当我尝试设置它时没有任何反应…不是新页面而不是错误页面什么都没有…如果我不通过角度更改路径我的路由器不会保持我正在寻找的范围…任何线索?

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);
         });
     }
}
强迫症不会让我把这个问题“公开”.所以,正如格罗纳指出的……嗨,我想你会在这个问题中找到你问题的答案: AngularJS $location not changing the path

还有一点价值广告.查看包含d3 http://www.fullscale.co/dangle/ 的这些指令

翻译自:https://stackoverflow.com/questions/13054944/location-not-working-in-angularjs-using-d3-js


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Ruby Cookbook

Ruby Cookbook

Lucas Carlson、Leonard Richardson / O'Reilly Media / 2006-7-29 / USD 49.99

Do you want to push Ruby to its limits? The "Ruby Cookbook" is the most comprehensive problem-solving guide to today's hottest programming language. It gives you hundreds of solutions to real-world pr......一起来看看 《Ruby Cookbook》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具