angular-timer icon indicating copy to clipboard operation
angular-timer copied to clipboard

Add timer in list: "timeoutId is not defined" error message

Open luidiva opened this issue 8 years ago • 3 comments

I have a ons-list with ng-repeat and a refresh button that reloads all list items bringing more from server. When time reaches zero or when I add a new timer at the top of the list, all timers get confused (the new one get the second item value and so). Only works when I reload the Controller. I tried using 1.2 and last versions and the problem happens in both.

<ons-list ng-repeat="(item, itemActiveTimer) in activeTimers"> <ons-list-item> <timer interval="1000" max-time-unit="'hour'" countdown="itemActiveTimer.TimeLeft" finish-callback="callbackTimer.finished(item, itemActiveTimer)">{{hhours}}:{{mminutes}}:{{sseconds}}</timer>

luidiva avatar May 30 '17 12:05 luidiva

The problem: I was using $rootScope to load activeTimers items. I had to manage to have everything inside $scope.

I thought I had solved it, but bug remains. If I reload the timer list in same scope, the timers get messed. Need help, please!

Thank you.

luidiva avatar May 31 '17 03:05 luidiva

I've found a solution, but every time I call "timer-reset" I receive the message in console:

ReferenceError {stack: "ReferenceError: timeoutId is not defined↵ at m.…www/vendors/onsen/js/angular/angular.min.js:51:68", message: "timeoutId is not defined"}

The solution was calling this code after I update $scope timer duration list:

$timeout(function(){ $scope.$broadcast('timer-reset'); $scope.$broadcast('timer-start'); });

Can anyone validade this solution, please?

Cheers

luidiva avatar May 31 '17 23:05 luidiva

No, I still get the same error when I use your code i.e. $timeout(function(){ $scope.$broadcast('timer-reset'); $scope.$broadcast('timer-start'); });

vinoadth avatar Jun 23 '17 07:06 vinoadth