I want to set currency all across the angular app. I have used currency pipe but have to call api for currency every-time in the component. But I want to set currency at once and used it across the whole application.
Currently i am using 123 | currency : 'INR'
.
Is there any alternate solution apart from creating a custom pipe? Or should i modify currency pipe if possible.
CodePudding user response:
You should not perform API calls in your pipes. This will lead to many, many API calls being performed. What you should do is create a service, which will hold the value of the currency you want to query for. This service can be injected in your pipe and can provide the value if already fetched.
CodePudding user response:
The only solution i am seeing from here is that i have to create a new custom pipe for currency then call an api in pipe itself and use it across the application.