Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the current time to access in the parent controller. #319

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/js/_timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ var timerModule = angular.module('timer', [])
hoursS: '=?',
daysS: '=?',
monthsS: '=?',
yearsS: '=?'
yearsS: '=?',
currentTime: '=?'
},
controller: ['$scope', '$element', '$attrs', '$timeout', 'I18nService', '$interpolate', 'progressBarService', function ($scope, $element, $attrs, $timeout, I18nService, $interpolate, progressBarService) {

Expand Down Expand Up @@ -199,7 +200,7 @@ var timerModule = angular.module('timer', [])
function calculateTimeUnits() {
var timeUnits = {}; //will contains time with units

if ($attrs.startTime !== undefined){
if ($attrs.startTime !== undefined && typeof $attrs.startTime === 'number'){
$scope.millis = moment().diff(moment($scope.startTimeAttr));
}

Expand Down Expand Up @@ -274,6 +275,8 @@ var timerModule = angular.module('timer', [])
$scope.mmonths = $scope.months < 10 ? '0' + $scope.months : $scope.months;
$scope.yyears = $scope.years < 10 ? '0' + $scope.years : $scope.years;

// expose the time (in milliseconds) for the parent controller
$scope.currentTime = $scope.millis;
}

//determine initial values of time units and add AddSeconds functionality
Expand Down
7 changes: 5 additions & 2 deletions dist/angular-timer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* angular-timer - v1.3.5 - 2017-03-09 2:18 PM
* angular-timer - v1.3.5 - 2017-07-07 4:34 PM
* https://github.com/siddii/angular-timer
*
* Copyright (c) 2017 Adrian Wardell
Expand Down Expand Up @@ -31,7 +31,8 @@ var timerModule = angular.module('timer', [])
hoursS: '=?',
daysS: '=?',
monthsS: '=?',
yearsS: '=?'
yearsS: '=?',
currentTime: '=?'
},
controller: ['$scope', '$element', '$attrs', '$timeout', 'I18nService', '$interpolate', 'progressBarService', function ($scope, $element, $attrs, $timeout, I18nService, $interpolate, progressBarService) {

Expand Down Expand Up @@ -281,6 +282,8 @@ var timerModule = angular.module('timer', [])
$scope.mmonths = $scope.months < 10 ? '0' + $scope.months : $scope.months;
$scope.yyears = $scope.years < 10 ? '0' + $scope.years : $scope.years;

// expose the time (in milliseconds) for the parent controller
$scope.currentTime = $scope.millis;
}

//determine initial values of time units and add AddSeconds functionality
Expand Down
4 changes: 2 additions & 2 deletions dist/angular-timer.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading