我有一个简单的应用程序,它包含在视图的HTML中
<input type="text" class="form-control" uib-datepicker-popup="{{format}}" ng-model="dt"
is-open="popup1.opened" min-date="minDate" max-date="maxDate"
datepicker-options="dateOptions" date-disabled="disabled(date, mode)"
ng-required="true" close-text="Close"
alt-input-formats="altInputFormats" />
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="open1()">
<i class="glyphicon glyphicon-calendar"></i></button>
</span>
这在控制器中
$scope.open1 = function() {
$scope.popup1.opened=true;
}
$scope.popup1 ={'opened': false}
$scope.dt = new Date();
当我单击演示项目中的日历图标时,日历会弹出,但它不在我的完整项目中,即使我复制/粘贴代码($ scope.popup1.opened确实从false更改为点击时为true。
这个完整的项目太大了,无法发布任何建议?
[更新]感谢您的帮助。需要注意的一点是,代码在一个小型项目中工作,但不是在一个完整的项目中,无论建议的重复问题如何。
但是,我已经接受了建议的副本,唉,它没有帮助。
$scope.SwallowClick = function($event)
{
if ($event.cancelable)
$event.preventDefault();
$event.stopPropagation();
return false; // don't handle event further
}
$scope.open1 = function($event)
{
$scope.SwallowClick($event);
$scope.popup1.opened=true;
return false; // don't handle event further
}
答案 0 :(得分:1)
您是否看过这个问题和接受的答案? ui.bootstrap.datepicker is-open not working with a button
尝试将$ event传递给你的ng-click处理程序,就像这样...
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="open1($event)">
<i class="glyphicon glyphicon-calendar"></i></button>
</span>
然后在你的javascript中,就像这样......
$scope.open1 = function($event) {
$event.preventDefault();
$event.stopPropagation();
$scope.popup1.opened=true;
}
$scope.popup1 ={'opened': false}
$scope.dt = new Date();
答案 1 :(得分:0)
D'哦! $scope.format
未定义(脸红)