Could it be possible to set an attribute for the startview of the datepicker?
For example, could the datepicker be opened showing years instead of months?
This is described here https://groups.google.com/forum/#!topic/angular/jeUtVuztXzI for AngularStrap
In the next release (already landed in master) you will be able to use datepicker-mode="day|month|year" in order to initialize or programmatically set/watch the current mode of the datepicker.
Related
I've made a date picker directive that uses a single date picker from the improvely datepicker library. It has two input tags and an OK button.
Date Picker Library
Single Date Picker Example
If I change the value of the input field via the keyboard the models get the desired value and calls to the server take place as expected. The problem arises when I use the date picker. The value of the model does not change. It still has the same value that I set via the keyboard.
But if I run document.getElementById('frompicker').value using the console it shows me the right date that I set using the datepicker.
If I don't set any value form the keyboard and only use the datepicker drop down, the values of the models are undefined.
I've tried a few solutions offered for Angular Boostrap UI Datepicker and Angular UI Datepicker. None of them work.
Edit after a comment
Code can be found here - https://plnkr.co/edit/HzkYzUajGlsZq5KhUwsx
Any help is greatly appreciated :)
You should sync scope after datepicker change via
$scope.$apply();
or
$scope.$evalAsync();
seems it 'apply.daterangepicker' event for your datepicker
I tried all the methods mentioned in different answers. My colleagues told that it's a bad idea to use $scope.$evalAsync() or $scope.$apply() unnecessarily. Our code base does not use digest, compile and the likes. So that was causing a hindrance.
I finally decided to detect the date change event as suggested by Valery Kozlov (the accepted answer) and manually changing the model.
I accessed the date like this.
$('#frompicker').val(); // can be done without jQuery as well
Changed the model using this.
// use Angular's $on to make things consistent if needed
$('#frompicker').on('apply.daterangepicker', function(ev, picker) {
scope.vm.from_date = $('#frompicker').val();
});
I am using angular material's datepicker inside my page, and was wondering whether it would be possible instead of dragging up and down to quickly move between months, to add two arrows that would move to the next/previous month similar to other more traditional date-pickers.
Is this possible, and if yes how should I go on about doing it.
How can I add buttons (Months) inside ExtJS datepicker (e.g., Jan. Feb. etc..)
I know that there's a dropdown (Months) available but I need to add buttons for easy navigation between Months.
Thanks in advance.
Does anyone have a solution to updating angular ui's disabled dates from a server response?
https://github.com/angular-ui/bootstrap/issues/779
You should create another directive that will require datepicker's controller. From your
directive you should call the refreshView of the datepicker to reevalute the disabled dastes.
Does anyone have example code for that?
I'm trying to use angular ui datepicker so that the disabled dates are read from a server response. I change the datepicker's min date to force it to refresh.
I saw another stackoverflow page where the user had it refresh, but it relied on the datepicker calendar being clicked. Another one used set the date min attribute as the value of another field.
For me, I have a completely separate field from the date picker. When changed, it sends an http request to the server, and on a successful response the available dates are updated.
The only problem with changing the min date to force a refresh is that sometime's there same but with different dates to disable. I'm looking into changing a datepicker option I do not use to a random value to force a refresh.
Does anyone have a better way? I saw cross controller communication via a service, but this is a different module. I also saw a github issue where the datepicker controller can be
I've found a simple solution to this problem using a decorator: https://gist.github.com/cgmartin/3daa01f910601ced9cd3
Then, you only need to call $scope.$broadcast('refreshDatepickers') to refresh the datepickers.
IMPORTANT: For more recent ui-bootstrap datepicker library, you may need to replace 'datepickerDirective' with 'uibDatepickerDirective' if you are using datepicker with uib-datepicker element or attribute.
The angular bootstrap datepicker has datepicker-options
This user listed the solution: https://github.com/angular-ui/bootstrap/issues/2189#issuecomment-225685104
bogdandrumen commented on Jun 13
Use datepicker-options="{minDate: yourScopeMinDate}"
which worked for me. I have two pickers, the second picker cannot be greater than the first one so if the first picker changes, the second picker's max date also changes.
The angular-ui-bootstrap datepicker isn't popping up when clicked after upgrading to version 0.11.
I've tried the recommended work around which is setting
is-open="dt.open" ng-focus="dt.open=true"
this works when it is enabled on just one calendar but not if there are two on the same page (both open and they are unusable). Anyone know a better work around that does not pollute the scope?
I've also tried changing ng-focus to ng-click and had no luck with that.
Two separate datepicker will require 2 distinct variables to control them:
is-open="dt.open" ng-focus="dt.open=true" // first datepicker
is-open="dt2.open" ng-focus="dt2.open=true" // second datepicker