我的应用程序中有这段 html 代码(之前定义了 ng-app 和 ng-controller 值):
<div>
<label for="projectSearchDateFrom"><%= Res("Projects.Search.From")%></label>
<input id="projectSearchDateFrom" type="text" ng-model="startDate" ui-date="dateOptions"/>
<img ng-show="hasStartDate()" ng-click="clearStartDate()" src="/_Layouts/ClientPortal/Images/layout/TA/delete-small.png" alt="<%= Res("ToolbarDialog.Clear")%> <%= Res("Projects.Search.From")%>" title="<%= Res("ToolbarDialog.Clear")%>" />
</div>
我的 AngularJS 控制器如下所示:
function ProjectSearchCtrl($scope) {
$scope.startDate = '';
$scope.hasStartDate = function () {
return $scope.startDate != '';
};
$scope.clearStartDate = function () {
$scope.startDate = '';
};
$scope.dateOptions = {
dateFormat: "yy-mm-dd",
showOn: "focus"
};
}
这完美地工作:感谢AngularUI,我正确设置了一个日期选择器,AngularJS绑定工作......
但是,如果我将 showOn 值更改为“button”或“both”(这两个可能的选项将实际显示 datepicker 按钮),则输入后的所有内容(包含 ui-date 属性)都将停止工作:ng-show、ng-单击...控制器甚至没有被调用。
版本(所有都是最新的):
- jQuery 1.7.2
- 角JS 1.0.0
- 角UI 0.1.0
- 铬 20