22 lines
443 B
JavaScript
22 lines
443 B
JavaScript
'use strict';
|
|
|
|
angular.module('forms').service('timeCounter', [
|
|
function(){
|
|
var _startTime, _endTime, that=this;
|
|
|
|
this.timeSpent = 0;
|
|
|
|
this.startClock = function(){
|
|
_startTime = Date.now();
|
|
console.log('Clock Started');
|
|
};
|
|
|
|
this.stopClock = function(){
|
|
_endTime = Date.now();
|
|
that.timeSpent = Math.abs(_endTime.valueOf() - _startTime.valueOf())/1000;
|
|
console.log('Clock Ended');
|
|
return that.timeSpent;
|
|
};
|
|
|
|
}
|
|
]); |