0
我试图将date
类型的input
绑定到模型。我可以绑定到time
字段,但我在date
字段中遇到问题。该HTML:为什么我的AngularJS ngModel绑定到时间输入,但没有绑定到日期输入?
<div ng-app ng-controller="HistoryCtrl">
<input type="date" nm-model="startDate" />
<input type="time" ng-model="startTime" />
<input type="date" nm-model="endDate" />
<input type="time" ng-model="endTime" />
<button ng-click="updateForm()">Update</button>
</div>
这是我的控制器(简体):
function HistoryCtrl($scope) {
$scope.result = {
result: 'success',
start: '2013-11-23 03:00:00',
end: '2013-11-24 16:30:00',
delta: 0.05681799352169
};
$scope.updateForm = function() {
$scope.updateTimespan($scope.result.start, $scope.result.end);
};
$scope.updateTimespan = function (start, end) {
$scope.startDate = start.split(" ")[0];
$scope.startTime = start.split(" ")[1];
$scope.endDate = end.split(" ")[0];
$scope.endTime = end.split(" ")[1];
}
}
这里有一个小提琴:http://jsfiddle.net/t3m6r/2/
我使用谷歌浏览器31.0.1650.57为Mac。当我点击“更新”按钮时,time
字段更新,但date
字段不更新。为什么?我是否doing it wrong?
也许是因为'纳米model'装置无关的角。 – Stewie
这个问题似乎是脱离主题,因为它是关于错字。 – Stewie