Angularjs自动收报机抛出错误,因为shift()不是一个函数

时间:2018-02-13 15:01:51

标签: angularjs

我正在尝试在AngularJs中滚动,我收到错误

  

shift()不是函数

请建议。

$scope.boxes = [];
$scope.moving = false;

$scope.moveLeft = function() {
  $scope.moving = true;
  $timeout($scope.switchFirst, 1000);
};
$scope.switchFirst = function() {
  $scope.boxes.push($scope.boxes.shift());
  $scope.moving = false;
  $scope.$apply();
};

$interval($scope.moveLeft, 2000);

更新

以下是我的控制器代码

$scope.memoryMap = [];
$scope.loading = true;
myService.getInfo(function(metrics) {
  if (metrics) {
    $scope.memoryMap = metrics.memoryMap;
  }
});

$scope.moving = false;
$scope.moveLeft = function() {
  $scope.moving = true;
  $timeout($scope.switchFirst, 1000);
};
$scope.switchFirst = function() {
  $scope.memoryMap.push($scope.memoryMap.splice(0, 1)[0]);
  $scope.moving = false;
  $scope.$apply();
};

$interval($scope.moveLeft, 2000);

0 个答案:

没有答案