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


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

查看所有标签

猜你喜欢:

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

Agile Web Application Development with Yii 1.1 and PHP5

Agile Web Application Development with Yii 1.1 and PHP5

Jeffrey Winesett / Packt Publishing / 2010-08-27

In order to understand the framework in the context of a real-world application, we need to build something that will more closely resemble the types of applications web developers actually have to bu......一起来看看 《Agile Web Application Development with Yii 1.1 and PHP5》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试