How to control datepicker object to call open/close method of datepicker. how to get datepicker object in another angularjs directive.
** HTML **
<input type="text" class="form-control" uib-datepicker-popup="{{format}}" ng-model="dt" is-open="popup1.opened" datepicker-options="dateOptions" ng-required="true" close-text="Close" alt-input-formats="altInputFormats" picker-date />
Directive:
module.directive('pickerDate', function() {
return {
restrict: 'A',
priority: 1,
require: 'ngModel',
link: function(scope, element, attrs, ctrl) {
console.log(ctrl)
element.on('click', function() {
});
// console.log();
}
};
});
When element click, how to call a method of datepicker? Any help would be appreciated. Thanks.
In the html, you have is-open="popup1.opened"
.
So you can control this by changing the boolean value of $scope.popup1.opened
.
$scope.popup1.opened = true; // open date picker
$scope.popup1.opened = false; // close date picker
If you want to change this when an element is clicked, you can use ng-click
.
For example:
<input type="text" class="form-control" uib-datepicker-popup="{{format}}" ng-model="dt" is-open="popup1.opened" datepicker-options="dateOptions" ng-required="true" close-text="Close" alt-input-formats="altInputFormats" picker-date />
<button type="button" ng-click="popup1.opened = !popup1.opened"></button>