If we detect angular is present, we can expose a directive:
<ANY moment date="scope.myDate" format="'lll'"></ANY>
'use strict';
/**
* @ngdoc directive
* @name momentjs.directive:moment
* @description
* # moment
* <ANY moment date="scope.iso8601date" format="'lll'"></ANY>
*/
angular.module('momentjs')
.directive('moment', function () {
return {
restrict: 'A',
scope: {
date: '=',
format: '='
},
link: function postLink(scope, element, attrs) {
if (scope.date) {
scope.formattedDate = moment(scope.date).format(scope.format);
element.text(scope.formattedDate);
}
}
};
});