Home Angularjs ticker throwing error as shift() is not a function
Reply: 0

Angularjs ticker throwing error as shift() is not a function

arjun
1#
arjun Published in 2018-02-13 15:01:50Z

I am trying to ticker in AngularJs, I am getting error as

shift() is not a function

Please suggest.

$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);

Update

The following is my controller code

$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);
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.325509 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO