如何不同时显示 angular ui datepicker 下拉列表

How to not show angular ui datepicker dropdown together

我用过this Bootstrap datepicker with angular directive。它工作正常。现在我需要再进行一点定制。单击第一个输入时,它将显示第一个下拉日历。单击另一个打开另一个日历下拉列表。我现在需要的只是那些下拉列表不会一起显示。我的意思是当第一个下拉菜单打开时,点击第二个输入将打开第二个下拉菜单,并且 第一个下拉菜单应该关闭 。同样,当第二个下拉菜单打开时,点击第一个输入将打开第一个日历下拉菜单,第二个下拉菜单应该关闭

所以,我需要做类似的事情:

when date1 is open
close date2 if it is open
when date2 is open
close date1 if it is open

但是,由于我是 angular 的新手,我不明白如何以 angular 的方式做到这一点。怎么做?

Plunker work

如果你只有 2 个日期选择器,那么你可以这样做来代替

 $scope.open[date] = true;

放这个

if(date=== 'date4'){
        $scope.open['date4'] = true;
        $scope.open['date5'] = false;
      }else{
        $scope.open['date4'] = false;
        $scope.open['date5'] = true;
      }

如果你有多个日期选择器,那么你可以调用循环来关闭它们。