Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
luidiva opened this issue May 30, 2017 · 3 comments
Open

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

luidiva opened this issue May 30, 2017 · 3 comments

Comments

@luidiva
Copy link

luidiva commented May 30, 2017

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
Copy link
Author

luidiva commented May 31, 2017

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 luidiva closed this as completed May 31, 2017
@luidiva luidiva reopened this May 31, 2017
@luidiva
Copy link
Author

luidiva commented May 31, 2017

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 luidiva changed the title Refreshing list of timers adding or removing problem Add timer in list: "timeoutId is not defined" error message May 31, 2017
@vinoadth
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants