While exploring the angularJS documentation, I came across various filter templates structured like this:
{{ date_expression | date : date : format}}
I'm curious about the meaning of date : date.
To test this out, I decided to run the following code: (JS Fiddle http://jsfiddle.net/6Jt4h/2/)
Here's the HTML:
<div ng-app="testApp" ng-controller="testCon">
{{dt1 | date : 'MM/dd/yyyy @ h:mma'}}<br>
{{dt1 | date : dt1 : 'MM/dd/yyyy @ h:mma'}}
</div>
And here's the Javascript:
var testApp = angular.module('testApp', []);
testApp.controller('testCon', function($scope) {
$scope.dt1 = new Date();
});
The output is as follows:
03/20/2014 @ 3:19PM
T3u 3PMr 20 2014 15:19:46 G3T-0500 (CentrPMl DPM2014lig3t Ti19e)
I'm puzzled by why the second line doesn't work properly, despite seeming to follow the correct syntax. Is it possible that the correct syntax should be:
{{ date_expression | date : format}}