【发布时间】:2018-01-04 19:51:43
【问题描述】:
我有一个由 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 模型不是日期对象
提前致谢
【问题讨论】:
-
你为什么不使用Angular内置的
$http-service?来自$.ajax的回调不会触发 Angular 的摘要循环,这可能会导致奇怪的问题。它不会解决这个问题,但它可能会解决一些奇怪的行为。 -
好的,谢谢,但我必须解决这个问题,客户正在等待更新!你知道如何解决这个问题吗?
标签: javascript angularjs date model