I am facing an issue while trying to connect an input
of type date
to a model. Although I am successful in binding to time
fields, I am encountering difficulties with date
fields. Below is the HTML snippet:
<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>
This is a simplified version of my controller:
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];
}
}
To view the behavior, check out this fiddle: http://jsfiddle.net/t3m6r/2/
Using Google Chrome 31.0.1650.57 for Mac, upon clicking the "Update" button, I observe that the time
fields get updated but not the date
fields. Could someone provide insights on why this might be happening? Am I maybe approaching it incorrectly?