Skip to content
This repository was archived by the owner on Feb 18, 2022. It is now read-only.

Conversation

@lucas3003
Copy link
Contributor

In one of my applications, I have two linked datepickers, one called "start" and other called "finish." When I choose the start date, I want the "finish" datepicker to move to the month I chose on "start" datepicker. I am now able to do that with this little change and setting date-min-limit.

I do not know if this is the best way to solve this problem; however, it worked for me so I wanted to contribute.

Please let me know if I was not clear enough or you need more details.

@45kb
Copy link
Member

45kb commented Dec 26, 2016

Hi @lucas3003 actually not bad!

Just check this out
https://github.com/lucas3003/angular-datepicker/blob/ecbaa92f8b9b609f8a1f6b9d76b017a37a6e8310/src/js/angular-datepicker.js#L363

and this

https://github.com/lucas3003/angular-datepicker/blob/ecbaa92f8b9b609f8a1f6b9d76b017a37a6e8310/src/js/angular-datepicker.js#L841

This is how watchers are deregistered, if you can please adapt the code both for date-min-limit and date-max-limit (makes more sense to watch both the attributes) and we can merge it !

If you want you can add watchers for all these attributes: min-date, max-date, date-format

These watchers must be implemented, here is the related issue in case https://github.com/720kb/angular-datepicker/issues/218 so that you can close the issue too :)

Thank you for your time 👍

@lucas3003
Copy link
Contributor Author

lucas3003 commented Dec 27, 2016

Hi, @45kb !

Thanks for the feedback!

I adapted the code and now the watcher is being deregistered. If you think it is good, I can implement to the other watchers you mentioned.

@45kb
Copy link
Member

45kb commented Dec 27, 2016

@lucas3003 IT IS GOOD! :)

Yes, if you can do it, feel free to add the other missing watchers (the one i listed), so you also close an issue with this PR ;)

Let me know.

@lucas3003
Copy link
Contributor Author

@45kb Glad you appreciated the work!

I implemented the 2 left watchers. I am just not sure if this is the best way to implement date-format watcher.

Thanks!

@45kb
Copy link
Member

45kb commented Dec 27, 2016

@lucas3003 looks ok, check my comments.
Also did you try them ? :)

Copy link
Member

@45kb 45kb left a comment

Choose a reason for hiding this comment

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

missing { } curlyes on if statments :)

}
})
, unregisterDateMaxLimitWatcher = $scope.$watch('dateMaxLimit', function dateMaxLimitWatcher(newValue){
if(newValue)
Copy link
Member

Choose a reason for hiding this comment

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

missing { } curlyes

resetToMaxDate();
})
, unregisterDateFormatWatcher = $scope.$watch('dateFormat', function dateFormatWatcher(newValue){
if(newValue)
Copy link
Member

Choose a reason for hiding this comment

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

missing { } curlyes

@lucas3003
Copy link
Contributor Author

@45kb I added the curlyes. I have tested in a small application I am working on.

@45kb 45kb merged commit fd6a3d7 into 720kb:master Dec 27, 2016
@45kb
Copy link
Member

45kb commented Dec 27, 2016

@lucas3003 done :) thank you

I will make a new version in a while so you can easily update it via npm or bower.

@45kb
Copy link
Member

45kb commented Dec 27, 2016

shipped in 2.1.8 https://github.com/720kb/angular-datepicker/releases/tag/2.1.8 thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants