[英]how to show date picker only on button click using angular bootstrap ui?
I want to show an AngularJS Bootstrap calendar on a button click only and restrict it on the click of input field, here is my code: 我只想在单击按钮时显示AngularJS引导日历,并在输入字段的单击中限制它,这是我的代码:
<input type="text"
onkeydown="return false;"
onkeyup="return false;"
id="dateFrom"
placeholder="{{datePlaceholder}}"
datepicker-popup="{{format}}"
ng-model="leadFormData.myDate"
is-open="field.opened"
close-text="Close"
name="Received On"
max="maxDate"
min="minDate"
data-ng-disabled="disableDate"
class="calendar-view" />
<button style="height:34px;" class="btn btn-default" ng-click="open($event)">
<i class="icon-calendar"></i>
</button>
Here is the open function called on the click of button , it is not working and I don't know why? 这是单击按钮时调用的打开功能,它不起作用,我不知道为什么? Kindly tell me where's i'am going wrong? 请告诉我我要去哪里错了?
$scope.open = function($event) {
$event.preventDefault();
$event.stopPropagation();
$scope.field.opened= true;
};
I used angular bootstrap ui date picker in my project. 我在项目中使用了角度引导ui日期选择器。 It may solved your problem. 它可以解决您的问题。
In HTML file: 在HTML文件中:
<input type="date"
id="startDate"
class="form-control"
onkeydown="return false;"
onkeyup="return false;"
datepicker-popup
data-ng-model="searchQuery.startDate"
is-open="startDateOpened"
datepicker-options="dateOptions"
show-button-bar="false" />
<button type="button" class="btn btn-default" ng-click="open($event)"><i class="fa fa-calendar"></i></button>
and in controller: 并在控制器中:
$scope.open = function($event) {
$event.preventDefault();
$event.stopPropagation();
$scope.startDateOpened = true;
};
$scope.dateOptions = {
formatYear: 'yy',
startingDay: 1
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.