如何在一个页面上至少拥有两个ui-bootstrap的datepicker? [英] How to have at least two datepickers of ui-bootstrap on a single page?
问题描述
< div>
< div class =form-horizontal left-left>
< input type =textdatepicker-popup =dd-MMMM-yyyyng-model =dtis-open =openedmin =minDatemax ='2015-06- 22datepicker-options =dateOptionsdate-disabled =disabled(date,mode)ng-required =true/>
< button class =btnng-click =open()>< span class =glyphicon glyphicon-calendar>< / span>< / button&
< / div>
< div class =form-horizontal left-left>
< input type =textdatepicker-popup =dd-MMMM-yyyyng-model =dtis-open =openedmin =minDatemax ='2015-06- 22datepicker-options =dateOptionsdate-disabled =disabled(date,mode)ng-required =true/>
< button class =btnng-click =open()>< span class =glyphicon glyphicon-calendar>< / span>< / button>
< / div>
< button type =submitclass =btn btn-default> Submit< / button>
< / div>
我刚刚从网站 http://angular-ui.github.io/bootstrap/#/datepicker 。他们互相冲突。当我点击< input>
字段打开一个日期戳,没有人可以正常打开,两者都打开了一秒钟,并立即消失。
我如何在单个页面上有几个日期提示?
而不是使用不同的功能可以使用不同的 is-open
属性,然后通过 ng-click
函数传递属性。您仍然需要不同的型号:
< div>
< div class =form-horizontal left-left>
< input type =textdatepicker-popup =dd-MMMM-yyyyng-model =dt1is-open =opened1min =minDatemax =' 22datepicker-options =dateOptionsdate-disabled =disabled(date,mode)ng-required =true/>
< button class =btnng-click =open($ event,'opens1')>< span class =glyphicon glyphicon-calendar>< / span>< /按钮>
< / div>
< div class =form-horizontal left-left>
< input type =textdatepicker-popup =dd-MMMM-yyyyng-model =dt2is-open =opened2min =minDatemax ='2015-06- 22datepicker-options =dateOptionsdate-disabled =disabled(date,mode)ng-required =true/>
< button class =btnng-click =open($ event,'opened2')>< span class =glyphicon glyphicon-calendar>< / span>< /按钮>
< / div>
< button type =submitclass =btn btn-default> Submit< / button>
< / div>
内部控制器:
$ scope.open = function($ event,opened){
$ event.preventDefault();
$ event.stopPropagation();
$ scope [打开] = true;
};
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>
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.
How may I have several datepickers on a single page?
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>
And inside controller:
$scope.open = function($event,opened) {
$event.preventDefault();
$event.stopPropagation();
$scope[opened] = true;
};
这篇关于如何在一个页面上至少拥有两个ui-bootstrap的datepicker?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!