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

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

内容简介:翻译自: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


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

查看所有标签

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

The Cult of the Amateur

The Cult of the Amateur

Andrew Keen / Crown Business / 2007-6-5 / USD 22.95

Amateur hour has arrived, and the audience is running the show In a hard-hitting and provocative polemic, Silicon Valley insider and pundit Andrew Keen exposes the grave consequences of today’s......一起来看看 《The Cult of the Amateur》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

在线进制转换器
在线进制转换器

各进制数互转换器

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具