2014-06-22 59 views
0

這是我在那裏我試圖用一個視圖「選項」主HTML:路由查看拋出錯誤:類型錯誤:無法讀取屬性「的childNodes」的未定義

<div class="container-fluid" > 
      <div class="row" > 
       <div class="col-sm-3 col-md-2 sidebar"> 
        <ul class="nav nav-sidebar"> 
         <li><a href="#/overview">Overview</a></li> 
         <li><a href="#/options">Options</a></li> 
         <li><a href="#/charts">Charts</a></li> 
        </ul> 

       </div> 
      </div> 
      <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main" ng-view=""> 
       <!-- Place for the views --> 

      </div> 

    </div> <!-- Container-fluid --> 

但是,當我點擊相應的錨點,我得到一個錯誤消息。

TypeError: Cannot read property 'childNodes' of undefined 
at compositeLinkFn (http://localhost/jqPlots/lib/js/angular.js:4018:36) 
at nodeLinkFn (http://localhost/jqPlots/lib/js/angular.js:4400:24) 
at compositeLinkFn (http://localhost/jqPlots/lib/js/angular.js:4015:15) 
at compositeLinkFn (http://localhost/jqPlots/lib/js/angular.js:4018:13) 
at compositeLinkFn (http://localhost/jqPlots/lib/js/angular.js:4018:13) 
at compositeLinkFn (http://localhost/jqPlots/lib/js/angular.js:4018:13) 
at compositeLinkFn (http://localhost/jqPlots/lib/js/angular.js:4018:13) 
at compositeLinkFn (http://localhost/jqPlots/lib/js/angular.js:4018:13) 
at compositeLinkFn (http://localhost/jqPlots/lib/js/angular.js:4018:13) 
at publicLinkFn (http://localhost/jqPlots/lib/js/angular.js:3920:30) 

這是腳本:

<script type="text/javascript"> 

    var VizApp = angular.module('VizApp', []); 

    VizApp.config(function($routeProvider){ 

     $routeProvider 
      .when('/overview',{ 
        controller : 'VizController', 
        templateUrl : 'views/overview.html' 
      }) 
      .when('/options', { 
       controller : 'VizController', 
       templateUrl : 'views/options.html' 
      }) 
      .when('/charts', { 
       controller : 'VizController', 
       templateUrl : 'views/charts.html' 
      }) 
      .otherwise({redirectTo : '/overview'}) 
    }); 

    var controllers = {}; 

    controllers.VizController = function($scope, $http){ 

     $("#yAxisVarDD").select2({placeholder : "Select Y Variable"}); 

     $scope.metrics= ['mean','sum','min','max']; 

     var headers = []; 
     var varType = []; 
     var records = []; 


     var csvPath; 

     $scope.getCsv = function(that){ 

      csvPath = 'csvs/' + that[0].files[0].name; 
      $http({method: 'GET', url: csvPath}). 
       success(function(data, status, headers, config) { 
        processData(data); 
       }). 
       error(function(data, status, headers, config) { 
      }); 
     }; 

     function processData(allText) { 
      var allTextLines = allText.split(/\r\n|\n/); 
      headers = allTextLines[0].split(','); 
      var previewSize = 10; 

      $.each(allTextLines[1].split(','),function(i,value){ 
       varType.push({ var : headers[i] , 
          type : isNaN(value) ? (isNaN(Date.parse(value)) ? "Character" : "Date") : "Numeric" 
       }); 

      }); 

      $.each(allTextLines.slice(1,allTextLines.length), function(i,thisRecord){ 
       records[i] = thisRecord.split(','); 
      }); 

      $scope.headers = headers; 
      $scope.varType = varType; 
      $scope.records = records; 

     } 


    }; 

    VizApp.controller(controllers); 
</script> 

這是我options.html

<div id="optionsPage" > 
<div class="varContainer cell" style="display:block"> 
    <h2 class="sub-header ">Variable Selection</h2> 
    <div class="panel panel-default inline" > 
     <div class="panel-heading"> 
      <h4 class="panel-title">Y-Axis</h4> 
     </div> 
     <div class="panel-body inline" > 
      <div class="inline selection-group" > 
       <p class="inline">       
        <select id="yAxisMetricDD" data-ng-options="metric for metric in metrics"> 
         <option></option>          
        </select><br> 
       </p>       
      </div> 
     </div> 
     </div>  
    </div> 
</div> 

我無法弄清楚什麼是創造這個錯誤。此外,我正在使用的選擇組件不顯示選項。這兩個可能有關係。請幫助。 謝謝。

回答

1

這可能是JS中的「yAxisVarDD」與HTML中的「yAxisMetricDD」之間的不匹配?

如果不是,請在http://jsfiddle.net中重現問題並鏈接到該問題,以增加獲得幫助的可能性。在您重現問題時,您可能會自己想出來。 :)

+0

+1:好評;;) – gkalpak

相關問題