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

access to data outside the directive

Open alainib opened this issue 9 years ago • 1 comments

I read the doc but didn't found a way to access to time outside the directive ( a getter for exemple )

For example, i display a coutdown of 1 hours( it work well ) on a page. On the same page there is somes training exercices to do. When the user finish the exercices he press a button, i need to get the remaining time left from the hour.

Is this possible ? thanks

alainib avatar Sep 29 '16 12:09 alainib

My solution, adding an id :

<timer end-time="endtime" id="timer">{{hours}}:{{minutes}}:{{seconds}}</timer>

And a service

  vm.getTimer = function(duree){
     var input = angular.element('#timer')[0]['innerText'];
     input = input.toLowerCase();
     var elements = input.split(":");
     return res = {
        "h":parseInt(elements[0]),
        "m":parseInt(elements[1]),
        "s":parseInt(elements[2]),
     };
  };

alainib avatar Oct 04 '16 12:10 alainib