问题描述
我想有一个页面上几个datepickers。但随着从默认溶液UI的引导它是不可能的,没有datepickers中的一个可以被打开。相互冲突。这里是我的code:
I want to have several datepickers on a page. But with the default solution from UI-Bootstrap it is not possible, no one of datepickers may be opened. The conflict with each other. Here is my code:
<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>
我只是做了日期选择器code的复制/粘贴从网站.他们互相冲突。当我点击&LT;输入方式&gt;
字段打开一个datepicker无人能正常打开,无论打开一秒钟,马上消失
I just did a copy/paste of the datepicker code from the site http://angular-ui.github.io/bootstrap/#/datepicker. They conflict with each other. When I click <input>
field to open a datepicker no one can be opened properly, both are opened for a second and immediately disappear.
我怎么可能有一个单页上几个datepickers?
How may I have several datepickers on a single page?
推荐答案
而不是使用不同的功能,你可以使用不同的是开放
属性,然后通过属性在通过 NG-点击
功能。你仍然需要不同的模型:
Rather than using a different function you can use a different is-open
attribute and then pass the attribute in through the ng-click
function. You still need different models:
<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;
};
这篇关于如何拥有UI的自举至少两个datepickers在单个页面上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!