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