我想用'MM/dd/yyyy
'格式显示日期。
日期过滤器工作但日期部分的格式不起作用。
以下是我的代码:
this.$filter('date')(this.BeginDate, 'MM/dd/yyyy')
这是您需要的快速示例,请检查您在控制器中调用过滤器的方式
angular.module('myApp',[])
.run(function($rootScope,$filter){
$rootScope.date = $filter('date')(new Date(),'MM/dd/yyyy'); // the issue is here
})
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp">
{{date}}
</div>