我有一个带有 <input type="date">
的表格.
当我在此输入中绑定(bind)数据时,它会显示日期 -1 天。
的HTML:
<div class="input-field col s12">
<label>Fecha Nacimiento </label>
<input type="date" class="form-control" id="fnac" name="fnac" ng-model="unapersona.fnac">
</div>
Controller :
$scope.cargarpersona = function(id) {
$http.get("modelos/personas_json.php?id="+id)
.success(function(data) {
$scope.unapersona = eval(data);
//... Other data
$scope.unapersona.fnac = new Date($scope.unapersona[0]["fnac"]);
//... Other data
})
.error(function(data) {
console.log('Error: ' + data);
});
}
Screen Capture
最佳答案
解决了!!
只是我把 ng-model-options = "{timezone 'UTC'} 进入输入日期
<input type="date" class="form-control" id="fnac" name="fnac" ng-model="unapersona.fnac" ng-model-options="{timezone:'UTC'}">
https://docs.angularjs.org/api/ng/directive/ngModelOptions
感谢您的回答和时间!
关于angularjs - Angular.js : Input date shows date -1 day,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36063131/