我想以“MM/dd/yyyy
”格式显示日期。
日期过滤器有效,但日期部分的该格式不起作用。
以下是我的代码:
this.$filter('date')(this.BeginDate, 'MM/dd/yyyy')
最佳答案
这是您需要的快速示例,请检查您在 Controller 中调用过滤器的方式
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>
关于javascript - Angular 日期过滤器的格式部分不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47865494/