0

I am using Angular Timer http://siddii.github.io/angular-timer/examples.html#/angularjs-single-timer

But I can't update the countdown variable. I see that I'm not the only one having this issue. I tried some "solutions" but this didn't work. What is the best way to make it work? Don't want to make a new countdown because this timer directive has a lot of features that I need. It's just that I can't update the countdown from a controller.

I have a select updating content which works perfect, except for the timer, I've added different time values

$scope.typeWods = [
    { label: 'EMOM',        value: 1,   time: 500    },
    { label: 'TABATA',      value: 2,   time: 900    },
    { label: 'POR VUELTAS', value: 3,   time: 800    },
    { label: 'AMRAP',       value: 4,   time: 1200   },
    { label: '21-15-9',     value: 5,   time: 700    }
];

The variable is updated, but the countdown property is not. Any good solution out there? Don't know what else to try.

2
  • 1
    Can you create a plnkr/fiddle for this? Commented Mar 17, 2015 at 14:17
  • Something like this? plnkr.co/edit/YDwnS5gOoQC2YppoxWq5 Commented Mar 17, 2015 at 14:42

2 Answers 2

2

angular-timer requires momentjs and humanize-duration libraries.

This is mentioned at - https://github.com/siddii/angular-timer#requirements

Updated plnkr: http://plnkr.co/edit/OkqS8fyZCiegsUjIW13L?p=preview

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, didn't understand why the plnkr doesn't work. But the real question is how to update the countdown variable, still not working.
@aluknot, please check the updated plnkr. We need to broadcast timer-set-countdown to update the countdown.
Thanks Vinay K. Now the plnkr work perfect but dunno why is not working on me. I had errors with humanize-duration but now i installed and updated the angular-timer librarie and other libraries too, i don't get errors now but is not working the change... $scope.$broadcast('timer-set-countdown', 50); is not executed. Is an ionic/cordova project
1

So i resolved this with Vinay K answer but instead of using timer-set-countdown i used timer-set-countdown-seconds to update the countdown and work perfect!

$scope.$broadcast('timer-set-countdown-seconds', $scope.variable);

$scope.$on('timer-set-countdown-seconds', function (e, seconds) {
    console.log(seconds);
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.