[英]Angularjs with bootstrap ui-datepicker
How to control datepicker object to call open/close method of datepicker. 如何控制datepicker对象以调用datepicker的打开/关闭方法。 how to get datepicker object in another angularjs directive.
如何在另一个angularjs指令中获取datepicker对象。
** HTML ** ** 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? 单击元素时,如何调用datepicker方法? Any help would be appreciated.
任何帮助,将不胜感激。 Thanks.
谢谢。
In the html, you have is-open="popup1.opened"
. 在html中,您具有
is-open="popup1.opened"
。 So you can control this by changing the boolean value of $scope.popup1.opened
. 因此,您可以通过更改
$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
. 如果要在单击元素时更改此设置,可以使用
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.