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

is it possible to create a button that saves the elapsed time?

Open tomatkins opened this issue 8 years ago • 6 comments

I have tried several times so I am just wondering if its actually possible.

tomatkins avatar Dec 14 '16 14:12 tomatkins

The answer is yes. But how is determined by how you are using angular-timer. If the following does not work please provide more detail such as using Angular 1 or Angular 2.

This may help. https://siddii.github.io/angular-timer/examples.html

Note, you may have to use rootScope depending on how you setup the directive.

For angular 1 you need to create a button that upon click will run some functions such as "getElapsedTime()". Then in the controller, assuming you are using the directive, you might try

getElementsByTagName('timer')[0] and then extract the value you want.

See: https://searchcode.com/codesearch/view/85611717/

wivancic avatar Dec 14 '16 15:12 wivancic

You can also use getElementByID see: https://github.com/siddii/angular-timer/commit/d39ccef6695e7acf80506509039b4365b56eca78

wivancic avatar Dec 14 '16 15:12 wivancic

Using angular 1. Its actually to integrate with an ionic application, so not sure if its best to use an ionic timer or pursue a cordova plug in. Thank you so much for your feedback!

tomatkins avatar Dec 14 '16 16:12 tomatkins

I am shooting in the dark here without knowing the full context. :)

Can you make sure the scripts are loaded within </head> instead of </body>?

I remembering seeing similar issue due to lazy loading

siddii avatar Dec 14 '16 16:12 siddii

I'm using a similar time in an ionic pluging. I started with angular-timer, but didn't need such an extensive directive. Also, I pulled it to use as a stand-alone factory for control purposes. I am now using a similar timer in Ionic 2. In Ionic 1 and angular 1 you can used things like $scope.$watch and $scope.$on

timer as factory 'meetingTimer' as function function getElapsedMS() { var totalTime = totalElapsedMs + elapsedMs; console.log("totalElpasedMS", totalTime); return totalTime; In controller: $scope.$watch(function() { return meetingTimer.getElapsedMS(); }, function(newVal, oldVal) { $scope.data.elapsedTime = meetingTimer.getElapsedMS(); },true);

wivancic avatar Dec 14 '16 17:12 wivancic

When I used as directive, I has to broadcast events as $rootScope.$broadcast in order to receive them in my App via controller and use commands like $scope.$broadcast('timer-stop using document.getElementsByTagName('timer')[0].stop(); resolved this.

Note, Just learning angular, ionic 1 and javascript when I was playing with this. Getting smarter every day.

wivancic avatar Dec 14 '16 17:12 wivancic