我做了一個請求返回一個頁面,返回一個日期格式爲「dd/MM/yyyy」的json。 我分析它和我在一個表中顯示它如下面json結果的格式日期和顯示在表中angularjs
<script>
angular.module("myApp",[])
.controller("mainController", function($scope, $http) {
$http.get('backList.php',{params: {dta: $scope.dataSelected}})
.success(function(data) { if("null" == data)
$scope.list="";
else {
$scope.list=data;
}
})
.error(function() { alert("Error retrieve data!"); });
}
});
</script>
<body ng-controller="mainController">
<div>
<table>
<tbody>
<tr ng-repeat="row in list">
<td align="center">{{row.dta_example}}</td>
<td align="center"><input class="calendar" type="text" ng-model="row.dta_example" ng-value="row.dta_example" /></td>
</tr>
</tbody>
</table>
</div>
</body>
一切工作正常,但我想使用類型=「數據」,使彈出出一個日曆,但如果我使用,我得到的一個錯誤告訴我row.dta_example需要是一個Date()對象。
,所以我沒有在get調用的成功方法是這樣的:
.success(function(data) { if("null" == data)
$scope.list="";
else {
$scope.list=data;
var i = 0;
for(var key in $scope.list){
$scope.list[i].dta_example=new Date.exactmatch(key.dta_example)
}
}
})
但失敗。
僅有約日期評論 - 我永遠不會再使用比momentjs其他任何東西,它會讓你的生活變得更輕鬆 - http://momentjs.com – Chris