angular-timer
angular-timer copied to clipboard
access to data outside the directive
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
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]),
};
};