Chain AngularJS $超时减少间隔

时间:2015-01-09 17:39:04

标签: javascript angularjs

我正在尝试创建一个AngularJS应用程序,它获取一个项目数组,然后循环遍历该数组(快速启动,然后放慢速度),直到它落在最终项目上。它应该模拟旋转车轮。但是,AngularJS在执行此操作时似乎抛出了内部错误。

  

TypeError:undefined不是返回logFn.apply的函数(console,args);

我在这里做错了还是有其他方法来创建这种行为?我现在写的方式

var timeout = 250;
vm.locations = ["A", "B", "C", "D", "E"];
vm.selectedLocation = "N/A";
vm.start = function () {
    getRandomLocation();
};

function getRandomLocation() {
    vm.selectedLocation = vm.locations[Math.floor(Math.random() * vm.locations.length)];
    timeout = timeout * 2;
    if (timeout < 5000) {
        $timeout(getRandomLocation(), timeout);
    } else {
        log(vm.selectedLocation);
    }
}

0 个答案:

没有答案