自定义时间过滤器

2017-06-12  本文已影响16人  MGd
var app = angular.module('app', []);
    app.controller('myContrller', ['$scope', function ($scope) {
        $scope.curDate = new Date;
    }]);

<p>{{curDate | date}}</p>

var app = angular.module('app', []);
    app.controller('myContrller', ['$scope', function ($scope) {
        $scope.curDate = new Date;
    }]);

<p>{{curDate | FormatStrDate}}</p>

app.filter('FormatStrDate', function() {
         return function(input) {
            var date=new Date(input);
            var formatDate=date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate();
            return formatDate
            }
        })
上一篇 下一篇

猜你喜欢

热点阅读