Custom Asynchronous filter to format date using translations - Angular Translate
This post is related to my previous post Introduction of translation in your project. In this, I tried to cover a basic concept of filter to format date in correct timezone locale mentioned in one of translation files.
PS: This post is for Angular1 and using Angular Translate for translation management.
Use Case Scenaio
Suppose, you are using translations and you want to store dateFormats in same file just to have everything in same place for that language.
In order to use that format and change your date appropriately, we need to create a custom filter that transforms the date into mentioned format. Now getting the format from translations folder(using $translate) is an asynchrounous processes so we have to wait for our format to convert and show on UI. I googled many posts and able to find a solution of creating a custom asynchrounous filter. Below is the full code:
To get started with Angular Translate, please visit my previous post here.
Hope this helps!