0

Hi I am using this angular countdown plugin

http://siddii.github.io/angular-timer/

and I need to use the directive multiple times within the same scope. The plugin broadcasts a 'timer-tick' event which I want to listen for but only from a specific directive.

Whats the best approach to this problem? I only seem to be getting the event broadcasted for the first instantiation of the element. In my case it has an $id of 38.

Here is the code in my controller

   $scope.$on('timer-tick', function (event, data){
            console.log('Timer is ticking = ', data,'event : ',event,'scope ',$scope);
});

HTML for first timer directive

 <span class="chat-time"><timer   interval="1000" countdown="currentEvent.duration"> {{hhours}} : {{mminutes}} : {{sseconds}} </timer></span> <!-- event duration for host -->

HTML for second timer directive

<timer  finish-callback="setUserStatus(true)"  interval="1000" countdown="speed_roommating.session_clock"> {{hhours}} : {{mminutes}} : {{sseconds}} </timer> 
Jamesed
  • 122
  • 5

1 Answers1

0

See the code at http://siddii.github.io/angular-timer/examples.html#/angularjs-polling-timer I think they've have an example of what you're trying to do.

$scope.$on('timer-tick', function (event, args) {
    $scope.timerConsole += $scope.timerType  + ' - event.name = '+ event.name + ', timeoutId = ' + args.timeoutId + ', millis = ' + args.millis +'\n';
});
Pancake_M0nster
  • 267
  • 5
  • 18
  • I saw that page but it doesn't give an example of using multiple timers with polling. I only seem to get the on tick event for the first timer on the page. – Jamesed Jun 23 '15 at 20:09
  • You should run some tests e.g if timers work as intended invidually (and the timer-tick event occurs). And while testing console.log() everything to see if any funny business is going on. – Pancake_M0nster Jun 23 '15 at 22:51
  • 1
    Just and update. I didnt get it to work however I did a work around by using the angularjs $interval timer to keep track of user progress. – Jamesed Jun 30 '15 at 22:09