angularjs – 什么是dateFilter,哪里可以找到更多关于它?

我正在通过关于指令的角度文档: http://docs.angularjs.org/guide/directive

页面上的一个例子(全部工作示例这里http://jsbin.com/osOQOYag/3/edit?html,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
    };
  });

在线上:

.directive('myCurrentTime',datefilter) {

我无法为我的生活找到有关.directive原型的任何信息,也无法在datefilter任何地方找到任何文档。此外,我知道datefilter是在AngularJS的未精简版本中找到的(尽管名称在缩小版本中消失)。任何人都可以提供一些有关datefilter和类似功能的指导(可能还有一个链接)?

日期过滤器文档在这里http://code.angularjs.org/1.2.5/docs/api/ng.filter:date

以下是说明过滤器注入的文档的一部分:http://code.angularjs.org/1.2.5/docs/guide/filter#using-filters-in-controllers-and-services

过滤器通常用于视图表达式({{myDate | date:’short’}}),但也可以在您的JS代码中使用。过滤器通过将字符串过滤器附加到过滤器名称(例如日期 – > datefilter)来注入。

app.controller('MyCtrl',function($scope,datefilter,lowercaseFilter){
  $scope.myDate = new Date();
  $scope.myDateFormatted = datefilter($scope.myDate,'shortDate');

  $scope.myString = 'Some String';
  $scope.myStringLowerCased = lowercaseFilter($scope.myString);
});

PLUNKER

相关文章

ANGULAR.JS:NG-SELECTANDNG-OPTIONSPS:其实看英文文档比看中...
AngularJS中使用Chart.js制折线图与饼图实例  Chart.js 是...
IE浏览器兼容性后续前言 继续尝试解决IE浏览器兼容性问题,...
Angular实现下拉菜单多选写这篇文章时,引用文章地址如下:h...
在AngularJS应用中集成科大讯飞语音输入功能前言 根据项目...
Angular数据更新不及时问题探讨前言 在修复控制角标正确变...