0
我想它像Angularjs:如何篩選
DD-MM-YYYY
格式化爲日期格式的數據的IAM從API得到的是如下
Mon Feb 13 2017 12:30:28 GMT+0000 (UTC)
有什麼幫助嗎?
我想它像Angularjs:如何篩選
DD-MM-YYYY
格式化爲日期格式的數據的IAM從API得到的是如下
Mon Feb 13 2017 12:30:28 GMT+0000 (UTC)
有什麼幫助嗎?
你可以把它轉換成View
或也controller
,
1)格式的查看日期:
<p>Date Formatted in view = {{ today | date:"dd-MM-y" }}</p>
{{ today | date:"dd-MM-y" }}
是角度的默認日期過濾器。
2)格式化在控制器中的日期:
$scope.date = $filter('date')($scope.today, "dd-MM-yyyy");
,在需要注入$filter
模塊的角。
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="datCtrl">
<p>Date Formatted in view = {{ today | date:"dd-MM-y" }}</p>
<p>Date Formatted in Controller = {{date}}</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('datCtrl', function($scope,$filter) {
$scope.today = new Date();
$scope.date = $filter('date')($scope.today, "dd-MM-yyyy");
});
</script>
<p>The date filter formats a date object to a readable format.</p>
</body>
</html>
請執行上面的代碼中
我認爲你正在尋找這樣的: http://stackoverflow.com/questions/22392328/how -to-format-date-in-angularjs –
'ng-bind =「date | date:'dd-MM-yyyy'」' –
@prakashtank thanks for the響應但它不起作用 – Raghav