2012-10-24 31 views
7

這是我第一次面對這個問題,不知道爲什麼。 我正在使用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); 
     }); 
    } 
} 
+1

嗨,我想你會在這個問題中找到你的問題的答案:[AngularJS $位置不改變路徑](http://stackoverflow.com/questions/11784656/angularjs -location-not-changing-the-path) – groner

+0

啊!非常感謝!我曾嘗試申請但我的語法不正確。非常感激!你想添加這個作爲迴應,所以我可以標記爲正確的? – climboid

回答