2017-04-09 77 views
0
var app1 = angular.module('sample', []); 
app1.controller('DemoCtrl', 
    function($scope, $http, $interval) { 
    var codes; 
    $scope.items = []; 
    $interval((function() { 
     if (codes && codes.length > 0) { 
     $scope.items.push({ 
      text: codes.shift() 
     }); 
     if ($scope.items.length > 10) { 
      return codes.push($scope.items.shift().text); 
     } 
     } 
    }), 300); 
    $http.get(location.href) 
     .success(function(contents) { 
     var each; 
     codes = []; 
     contents = contents.split('\n'); 
     while (contents.length > 0) { 
      each = contents.shift(); 
      if (each.trim()) { 
      codes.push(each.substr(0, 80)); 
      } 
     } 
     return codes; 
     }); 
    }); 

錯誤:NG:AREQ 糟糕論點 參數 'demoCtrl' 不是錯誤:[NG:AREQ]參數 'demoCtrl' 不是一個函數,得到了不確定

+0

可能是字母大小寫問題? 'demoCtrl'vs'DemoCtrl' – jediz

回答

1

你的控制器名稱爲'DemoCtrl'不是'demoCtrl'您可能正在使用ng-controller或其他組件分配。

同步它們,所以案件是一樣的

相關問題