Angular Date Filter's format section not working

115 Views Asked by At

I want to show date with format 'MM/dd/yyyy'.
The date filter working but that format of date part doesn't working.

the following one is my code:

this.$filter('date')(this.BeginDate, 'MM/dd/yyyy')
1

There are 1 best solutions below

0
On BEST ANSWER

here is a quick example of what you need, check the way you call the filter in your 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>