我正在使用AngularJS调用Web API来存储数据,问题是JavaScript在输入框中的null
日期为1/1/1970
。
如何在到达日期时使输入框为空?null
?
读取数据时
<div class="form-group has-error">
<label class="title_lable">Date Of Certificate:</label>
<input type="date" class="form-control input-sm" ng-model="cdate">
</div>
在html表格中显示数据时
<tbody>
<tr ng-repeat="d in lifeSupportsdata" ng-click="showInEdit(d)" ng-class="{selected:d=== selectedRow}">
<td>{{d.Life}}</td>
<td>{{d.Date_Issue | date : "dd/MM/yyyy" }}</td>
<td>{{d.Date_Expiry | date : "dd/MM/yyyy" }}</td>
角度控制器
$scope.showInEdit = function (member) {
console.log(member);
$scope.selectedRow = member;
$scope.syskey = member.Sys_Key;
$scope.life = '' + member.Life_Key + '';
$scope.cdate = new Date(member.Date_Issue);
$scope.edate = new Date(member.Date_Expiry);
任何帮助或想法,如何显示空输入框而不是1/1/1970
。
提前致谢
答案 0 :(得分:0)
<div class="form-group has-error">
<label class="title_lable">Date Of Certificate:</label>
<input type="date" class="form-control input-sm"
ng-model="(cdate == null || cdate == '1/1/1970') ? '' : cdate">
</div>
答案 1 :(得分:0)
if (member.Date_Expiry == null) {
$scope.edate = '';
} else $scope.edate = new Date(member.Date_Expiry);