Add timer in list: "timeoutId is not defined" error message
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>
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.
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
No, I still get the same error when I use your code i.e. $timeout(function(){ $scope.$broadcast('timer-reset'); $scope.$broadcast('timer-start'); });