Angularjs   发布时间:2022-04-20  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了angularjs – Angular-Strap datepicker的动态放置大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有角度带子日期选择器放置字段的问题.
有没有办法动态制作展示位置属性,以便它不会与窗口高度重叠.[bottom,top].

这是ng-repeat中的指令.

我们使用此方法获得的placement属性一个空字符串,因为placment属性没有2路绑定.

<div class="time_status_container" 
     ng-right-click="calculatePosition($event)" 
     ng-blur="toggleDatepicker()" 
     tabindex="-1" 
     style="outline:none;">

  <div bs-datepicker
       template="template.html"
       container="body"
       ng-model="start_date"
       data-trigger="manual"
       bs-show="show"
       placement="{{showDatePicker.position}}"
       data-max-date="{{ project.END_DATE }}">
  </div>

  Show Datepicker
</div>

用这个指令触发了datepicker.

directives
.directive('ngRightClick',["$parse",function($parsE) {
return function(scope,element,attrs) {
    var fn = $parse(attrs.ngRightClick);
    element.bind('contextmenu',function(event) {
        scope.$apply(function() {
            event.preventDefault();
            fn(scope,{$event:event});
        });
    });
};
}]);

这是应该动态更改的指令.

directives
.directive('stone',function() {
    return {
        reStrict: 'E',replace:true,templateUrl: 'template.html',controller:function($scopE){

            $scope.toggleDatepicker = function(typE){
                if(type == "start"){
                    $scope.showDatePicker['start'] = true;
                    $scope.showDatePicker['end'] = false;
                }
                else if(type == "end"){
                    $scope.showDatePicker['start'] = false;
                    $scope.showDatePicker['end'] = true;
                }
                else{
                    $scope.showDatePicker['start'] = false;
                    $scope.showDatePicker['end'] = false;
                }

                console.log($scope.showDatePicker)
            };

            $scope.calculatePosition = function(E){
                var mouseTopPosition = e.clientY || e.pageY;
                var lastKNowWindowHeight = $scope.getLastKNownWindowHeight();
                var datePickerStoneHeight = $scope.getDatePickerStoneHeight;
                var position;

                if((mouseTopPosition + datePickerStoneHeight) > lastKNowWindowHeight){
                    position = "top";
                }
                else{
                    position = "bottom";
                }

                $scope.showDatePicker = { start:true,position:position };
            };
        }
    };
});

解决方法

当然,使showDatePicker.position成为一个确定正确值并返回该值的函数.

大佬总结

以上是大佬教程为你收集整理的angularjs – Angular-Strap datepicker的动态放置全部内容,希望文章能够帮你解决angularjs – Angular-Strap datepicker的动态放置所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。