-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<title>Angular JSON Date Converter Filter Example</title> | ||
<script data-require="angular.js@*" data-semver="1.4.2" src="https://code.angularjs.org/1.4.2/angular.js"></script> | ||
<script src="script.js"></script> | ||
</head> | ||
|
||
<body ng-app="jsonDateConverterExample"> | ||
<h2>Angular JSON Date Converter Filter Example</h2> | ||
<div ng-controller="JsonDateController as dateCtrl"> | ||
<div> | ||
Original JSON Date : {{sampleJsonDate}} | ||
</div> | ||
<h3>JavaScript dates in different formats :</h3> | ||
<div>{{ sampleJsonDate | jsonDate }}</div> | ||
<div>{{ sampleJsonDate | jsonDate : 'yyyy-MM-dd' }}</div> | ||
<div>{{ sampleJsonDate | jsonDate :'medium' }}</div> | ||
<div>{{ sampleJsonDate | jsonDate : 'yyyy-MM-dd HH:mm:ss Z' }}</div> | ||
</div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var jsonDateConverterExample= angular.module('jsonDateConverterExample', []) | ||
.controller('JsonDateController', ['$scope', function($scope) { | ||
$scope.sampleJsonDate = '\/Date(1433913313004-0800)\/'; | ||
}]); | ||
|
||
jsonDateConverterExample.filter('jsonDate', ['$filter', function ($filter) { | ||
return function (input, format) { | ||
return (input) ? $filter('date')(parseInt(input.substr(6)), format) : ''; | ||
}; | ||
}]); |