我想在一个页面上有几个日期选择器。但是使用UI-Bootstrap的默认解决方案是不可能的,不能打开任何日期选择器。相互冲突。这里是我的代码:
<div> <div class="form-horizontal pull-left"> <input type="text" datepicker-popup="dd-MMMM-yyyy" ng-model="dt" is-open="opened" min="minDate" max="'2015-06-22'" datepicker-options="dateOptions" date-disabled="disabled(date,mode)" ng-required="true"/> <button class="btn" ng-click="open()"><span class="glyphicon glyphicon-calendar"></span></button> </div> <div class="form-horizontal pull-left"> <input type="text" datepicker-popup="dd-MMMM-yyyy" ng-model="dt" is-open="opened" min="minDate" max="'2015-06-22'" datepicker-options="dateOptions" date-disabled="disabled(date,mode)" ng-required="true" /> <button class="btn" ng-click="open()"><span class="glyphicon glyphicon-calendar"></span></button> </div> <button type="submit" class="btn btn-default">Submit</button> </div>
我刚刚从站点http://angular-ui.github.io/bootstrap/#/datepicker复制/粘贴日期代码代码。它们相互冲突。当我点击< input>字段打开日期选择器,没有人可以正确打开,两者都打开一秒钟,立即消失。
我如何在一个页面上有几个日期选择器?
而不是使用不同的函数,您可以使用不同的is-open属性,然后通过ng-click函数传递属性。您仍然需要不同的型号:
原文链接:https://www.f2er.com/angularjs/146343.html<div> <div class="form-horizontal pull-left"> <input type="text" datepicker-popup="dd-MMMM-yyyy" ng-model="dt1" is-open="opened1" min="minDate" max="'2015-06-22'" datepicker-options="dateOptions" date-disabled="disabled(date,mode)" ng-required="true"/> <button class="btn" ng-click="open($event,'opened1')"><span class="glyphicon glyphicon-calendar"></span></button> </div> <div class="form-horizontal pull-left"> <input type="text" datepicker-popup="dd-MMMM-yyyy" ng-model="dt2" is-open="opened2" min="minDate" max="'2015-06-22'" datepicker-options="dateOptions" date-disabled="disabled(date,mode)" ng-required="true" /> <button class="btn" ng-click="open($event,'opened2')"><span class="glyphicon glyphicon-calendar"></span></button> </div> <button type="submit" class="btn btn-default">Submit</button> </div>
内控制器:
$scope.open = function($event,opened) { $event.preventDefault(); $event.stopPropagation(); $scope[opened] = true; };