H
H
habrazhitel2014-11-28 01:54:19
JavaScript
habrazhitel, 2014-11-28 01:54:19

How can I change the currency of a site using angular?

That is, there is a field where the price of the goods is displayed (just in numbers, without a dollar sign or other currency). How to make it so that, depending on which currency the user has chosen (let's say in the select), in such a currency it is shown. Suppose in dollars we just substitute the dollar, in rubles, depending on the exchange rate (which we set in the settings). For some reason it seems to me that this needs to be done through directives?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Nikita Gushchin, 2014-11-28
@iNikNik

Use filters.
<span>{{price | myCurrencyFilter}}</span>

D
Dmitry Arushanov, 2014-11-28
@daruwanov

There is a standard currency in which prices are clogged.
you need to have somewhere data on the ratio of one currency to another.
And when changing the currency display for prices. Based on this ratio, we translate a new figure. and the currency symbol can be yes through custom filters.

S
Sergey Romanov, 2014-11-28
@Serhioromano

As I understand it, you need to show the same as it was introduced. That is, the user of the cro views has no choice to change the currency? I mean that in the product list, each product is displayed in a different currency.
Well, it's elementary. As entered so and tobrazite. On the form 2 fields are the text for the price and the list for currencies. In the product list, show first the price, then the currency. So it turns out that they entered it and showed it.
And if you already need the buyer to be able to switch currencies, and view products in one currency, displayed in another currency, then you need a filter, as you have already been told. How to solve this filter, it can be done in different ways.
I would recommend, but I don't know how you did it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question