繁体   English   中英

带有引导UI-datepicker的AngularJS

[英]Angularjs with bootstrap ui-datepicker

如何控制datepicker对象以调用datepicker的打开/关闭方法。 如何在另一个angularjs指令中获取datepicker对象。

** 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 />

指示:

   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();
        }
      };
    });

单击元素时,如何调用datepicker方法? 任何帮助,将不胜感激。 谢谢。

在html中,您具有is-open="popup1.opened" 因此,您可以通过更改$scope.popup1.opened的布尔值来控制它。

$scope.popup1.opened = true; // open date picker
$scope.popup1.opened = false; // close date picker

如果要在单击元素时更改此设置,可以使用ng-click 例如

<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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM