FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

trigger $digest loop when use finishCallback by hjzheng · Pull Request #273 · siddii/angular-timer · GitHub

This repository was archived by the owner on Jun 23, 2026. It is now read-only.
/ angular-timer Public archive
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (5) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
14 changes: 11 additions & 3 deletions app/js/_timer.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var timerModule = angular.module('timer', [])
monthsS: '=?',
yearsS: '=?'
},
controller: ['$scope', '$element', '$attrs', '$timeout', 'I18nService', '$interpolate', 'progressBarService', function ($scope, $element, $attrs, $timeout, I18nService, $interpolate, progressBarService) {
controller: ['$scope', '$element', '$attrs', '$timeout', 'I18nService', '$interpolate', 'progressBarService', '$rootScope', function ($scope, $element, $attrs, $timeout, I18nService, $interpolate, progressBarService, $rootScope) {

// Checking for trim function since IE8 doesn't have it
// If not a function, create tirm with RegEx to mimic native trim
Expand Down Expand Up @@ -298,7 +298,11 @@ var timerModule = angular.module('timer', [])
$scope.millis = 0;
calculateTimeUnits();
if($scope.finishCallback) {
$scope.$eval($scope.finishCallback);
if ($rootScope.$$phase) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Is there a way to avoid this undocumented API usage?

hjzheng Aug 16, 2016
edited
Loading

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

No, As far as I know It is a only way to detect whether the $digest loop is running.

$scope.$evalAsync($scope.finishCallback);
} else {
$scope.$apply($scope.finishCallback);
}
}
return;
}
Expand All @@ -318,7 +322,11 @@ var timerModule = angular.module('timer', [])
else if ($scope.countdown <= 0) {
$scope.stop();
if($scope.finishCallback) {
$scope.$eval($scope.finishCallback);
if ($rootScope.$$phase) {
$scope.$evalAsync($scope.finishCallback);
} else {
$scope.$apply($scope.finishCallback);
}
}
}

Expand Down
24 changes: 15 additions & 9 deletions dist/angular-timer.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/**
* angular-timer - v1.3.4 - 2016-05-01 9:52 PM
* https://github.com/siddii/angular-timer
* angular-timer - v1.3.5 - 2016-08-16 4:33 PM
* https://github.com/june07/angular-timer
*
* Copyright (c) 2016 Siddique Hameed
* Licensed MIT <https://github.com/siddii/angular-timer/blob/master/LICENSE.txt>
* Copyright (c) 2016 Adrian Wardell
* Licensed MIT <https://github.com/june07/angular-timer/blob/master/LICENSE.txt>
*/
var humanizeDuration = require("humanize-duration");
var moment = require("moment");
var timerModule = angular.module('timer', [])
.directive('timer', ['$compile', function ($compile) {
return {
Expand Down Expand Up @@ -35,7 +33,7 @@ var timerModule = angular.module('timer', [])
monthsS: '=?',
yearsS: '=?'
},
controller: ['$scope', '$element', '$attrs', '$timeout', 'I18nService', '$interpolate', 'progressBarService', function ($scope, $element, $attrs, $timeout, I18nService, $interpolate, progressBarService) {
controller: ['$scope', '$element', '$attrs', '$timeout', 'I18nService', '$interpolate', 'progressBarService', '$rootScope', function ($scope, $element, $attrs, $timeout, I18nService, $interpolate, progressBarService, $rootScope) {

// Checking for trim function since IE8 doesn't have it
// If not a function, create tirm with RegEx to mimic native trim
Expand Down Expand Up @@ -307,7 +305,11 @@ var timerModule = angular.module('timer', [])
$scope.millis = 0;
calculateTimeUnits();
if($scope.finishCallback) {
$scope.$eval($scope.finishCallback);
if ($rootScope.$$phase) {
$scope.$evalAsync($scope.finishCallback);
} else {
$scope.$apply($scope.finishCallback);
}
}
return;
}
Expand All @@ -327,7 +329,11 @@ var timerModule = angular.module('timer', [])
else if ($scope.countdown <= 0) {
$scope.stop();
if($scope.finishCallback) {
$scope.$eval($scope.finishCallback);
if ($rootScope.$$phase) {
$scope.$evalAsync($scope.finishCallback);
} else {
$scope.$apply($scope.finishCallback);
}
}
}

Expand Down
10 changes: 5 additions & 5 deletions dist/angular-timer.min.js

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

Loading

Back | FazBrowse Home | New Git URL