0

I have a list of dates like this:

$scope.months = [];

for (var i = 0; i < 12; i++)
{
  var month = new Date();
  month.setMonth(i);
  month.setDate(1);
  $scope.months[i] = month;
}

And use them in HTML like this:

<li number="{{$index}}" ng-repeat="month in months" parent-id="slider-month">
    <div>{{month | date:'MMMM' }}</div>
</li>

The problem starts when I translate the $locale to another language this ng-repeat is not refreshed. Tried with $scope.$apply() but no luck.

Currently I call the function to completely redo the looping and creating that list but that is visible on the frontend. Any other ways?

Other way would be to crete list of translations and that's it but just wondering how to solve this kind of problems.

Mikko Viitala
  • 8,344
  • 4
  • 37
  • 62
Reeebuuk
  • 1,363
  • 2
  • 21
  • 42

1 Answers1

0

Looks like this is a known issue. Angularjs and $locale

{{month | date:dateFormat }}

The closes you can come is changing the date formats yourself. Codepen

Community
  • 1
  • 1
Sinetheta
  • 9,189
  • 5
  • 31
  • 52