我有一个由ng-repeat填充的输入类型日期,我希望能够更改日期值,但它没有更新:
查看:
// displaying the date value
<tr ng-repeat="sf in selectedFacture">
<td><input type="date" class="dateCom" ng-model= "sf.dateCom | date" value="{{sf.dateCom}}"/></td>
<td><input type="date" class="dateRec" ng-model= "sf.dateRec | date" value="{{sf.dateRec}}"/></td>
<td ng-click="updateFacture(sf,id)"> update </td>
</tr>
JS:
//sending the date to server side and update the database
$scope.updateFacture=function(sf,id){
// getting the changed date
var editDateCom = sf.dateCom,
editDateRec = sf.dateRec;
var data = {
"id":id,
"editDateCom":editDateCom,
"editDateRec":editDateRec
};
var options = {
type : "get",
url : url,
data: data,
dataType: 'json',
async : false,
cache : false,
success : function(response,status) {
$scope.getClients();
},
error:function(request,response,error){
alert("Erro")
}
};
$.ajax(options);
}
);
其他数据在同一功能中成功更新,但问题在于日期,它根本不起作用,控制台记录了以下内容:
错误:ngModel:datefmt 模型不是日期对象
提前致谢
答案 0 :(得分:0)
您在ng-model指令中使用了过滤器,这是错误的
ng-model= "sf.dateCom | date"
正确使用
ng-model= "sf.dateCom"
使用{{}}