What is dateFilter and where can I find out more about it?

Viewed 8455

I am going through the Angular documentation on directives: http://docs.angularjs.org/guide/directive

One of the examples on the page (full working example here http://jsbin.com/osOQOYag/3/edit?html,js,output

angular.module('docsTimeDirective', [])
  .controller('Ctrl2', function($scope) {
    $scope.format = 'M/d/yy h:mm:ss a';
  })
  .directive('myCurrentTime', function($interval, dateFilter) {

    function link(scope, element, attrs) {
      var format,
          timeoutId;

      function updateTime() {
        element.text(dateFilter(new Date(), format));
      }

      scope.$watch(attrs.myCurrentTime, function(value) {
        format = value;
        updateTime();
      });

      element.on('$destroy', function() {
        $interval.cancel(timeoutId);
      });

      // start the UI update process; save the timeoutId for canceling
      timeoutId = $interval(function() {
        updateTime(); // update DOM
      }, 1000);
    }

    return {
      link: link
    };
  });

On the line:

.directive('myCurrentTime', function($interval, dateFilter) {

I cannot for the life of me find any information on the .directive prototype and cannot find any documentation on dateFilter anywhere either. Also, I know that dateFilter is found in the un-minified version of AngularJS (although the name disappears in the minified version). Can anyone provide some guidance (and possibly a link) explaining more about dateFilter and similar functions?

1 Answers
Related