Skip to content

Commit

Permalink
Fix date range reset bug
Browse files Browse the repository at this point in the history
  • Loading branch information
reicolina committed May 20, 2016
1 parent 8137287 commit 26216e8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
9 changes: 7 additions & 2 deletions dist/ngDateRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@
// This will allow us to control the component externally
scope.$watch('externalModel', function () {
if (!scope.externalModel.start && !scope.externalModel.end) {
// if the model got cleared then reflect that in the view
scope.dt = undefined; // null doesn't work!
// 'dt' is undefined when loading the component for the first time
// so we set it to a falsy vakue to triger the dt 'watch'
if (scope.dt === undefined) {
scope.dt = null;
} else {
scope.dt = undefined;
}
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion dist/ngDateRange.min.js

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-calendar",
"version": "1.1.0",
"version": "1.1.1",
"description": "Angular date range picker",
"main": "app.js",
"scripts": {
Expand Down
9 changes: 7 additions & 2 deletions src/ngDateRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@
// This will allow us to control the component externally
scope.$watch('externalModel', function () {
if (!scope.externalModel.start && !scope.externalModel.end) {
// if the model got cleared then reflect that in the view
scope.dt = undefined; // null doesn't work!
// 'dt' is undefined when loading the component for the first time
// so we set it to a falsy vakue to triger the dt 'watch'
if (scope.dt === undefined) {
scope.dt = null;
} else {
scope.dt = undefined;
}
}
});
}
Expand Down

0 comments on commit 26216e8

Please sign in to comment.