sourcecode

기본 통화 기호(달러 기호)가 아닌 각도 js에서 특정 통화 기호(내 경우 루피 기호)를 가져오는 방법

copyscript 2023. 2. 28. 23:43
반응형

기본 통화 기호(달러 기호)가 아닌 각도 js에서 특정 통화 기호(내 경우 루피 기호)를 가져오는 방법

각도 js에 '통화'를 사용하면 달러 기호가 표시됩니다.요건에 따라 필요한 통화 기호를 얻는 방법.마치 지금 나는 화폐로 루피 기호를 표시하는 방법을 알아야 한다.요구 사항이 다른 시기에 이 통화를 다른 기호로 사용하는 방법을 설명할 수 있다면 큰 도움이 될 것입니다.

샘플:

Item Price<span style="font-weight:bold;">{{item.price | currency}}</span>

만약 내 아이템.가격이 200이라면.여기 200달러가 표시됩니다.달러 대신 루피 기호를 표시해야 합니다.

통화 기호를 각도 js로 표시하려면 아래 통화 기호에 HTML 엔티티를 제공해야 합니다. through 코드와 템플릿의 예와 사용법을 보여 줍니다.

Euro 템플릿의 예:

Item Price<span style="font-weight:bold;">{{price | currency:"&euro;"}}</span>

루피의 예:

Item Price<span style="font-weight:bold;">{{price | currency:"&#8377;"}}</span>

아래 URL도 확인해 주세요.

http://www.cs.tut.fi/~jkorpela/http/euro.http://http://www.cs.tut.fi/

컨트롤러에서:

컨트롤러에 $filter 삽입

$scope.price=$filter('currency')($scope.price,'&euro;')

다음과 같은 기호 매개 변수를 사용할 수 있습니다.

Item Price<span style="font-weight:bold;">{{item.price | currency[:symbol]}}</span>

예:

Item Price<span style="font-weight:bold;">{{item.price | currency:"USD$"}}</span>

다음을 참조하십시오.

http://docs.angularjs.org/api/ng.filter:currency

파티에 늦었지만 마지막 프로젝트 때 이 필터 작업을 했어요.

ISO 4217 통화 코드(3글자 길이, 예:USD, EUR 등) isoCurrency는 올바른 형식, 분수 크기 및 기호를 출력할 수 있습니다.

// in controller
$scope.amount = 50.50;
$scope.currency = 'USD';

// in template
{{ amount | isoCurrency:currency }} // $50.50

INR 통화에 대한 간단한 솔루션 제공.

기호를 표시하려면

Item Price<span style="font-weight:bold;">{{item.price | currency:'INR'}}</span>

또는

Item Price<span style="font-weight:bold;">{{item.price | currency:'INR':'symbol'}}</span>

또는

Item Price<span style="font-weight:bold;">{{item.price | currency:'INR':'symbol-narrow'}}</span>

결과는 다음과 같습니다. result 140 . 00

또는 기호 대신 코드를 표시하려면 다음을 사용하십시오.

 Item Price<span style="font-weight:bold;">{{item.price | currency:'INR':'code'}}</span>

결과는 다음과 같습니다.INR 140.00

마찬가지로 INR(India Code) 대신 다른 국가의 코드를 확인하고 대체할 수 있습니다.

통화 기호는 다음과 같이 기본 $ 기호에서 다른 기호로 변경할 수 있습니다.
HTML 템플릿바인딩

 {{ currency_expression | currency[:symbol] }} 

자바스크립트

 $filter('currency')(amount[, symbol]) 

예를 들어 다음과 같이 루피 기호(이 경우)를 표시할 수 있습니다.
HTML 템플릿바인딩

Item Price<span style="font-weight:bold;">{{price | currency:"&#8377;"}}</span> 

또는

자바스크립트

$scope.price=$filter('currency')($scope.price,"&#8377;")

또한 다음과 같이 필요에 따라 기호 대신 텍스트를 추가할 수 있습니다.

Item Price<span style="font-weight:bold;">{{price | currency:"rupee"}}</span> 

주의: HTML에 직접 루피 기호를 복사하는 것은 작동하지 않습니다.

"" 참조JS 통화 문서

$는 각 통화 필터의 기본 기호입니다.다른 기호로 결과를 얻으려면, 예를 들어 Ruffe(),)를 앱에서 명시적으로 정의해야 합니다.symbol 기호를 표시하려면 통화 옵션을 추가하면 됩니다.

예:

<span> <b>{{i.price | currency : '&#8377;' }}</b> </span>

&#8377;【심볼】HTML 【HTML】

<h2>{{8.99 | currency:'INR':true}}</h2>

Angular JS docs Link에 따르면 통화를 변경할 수 있습니다.

Item Price<span style="font-weight:bold;">{{price | currency:[symbol]}}</span>
Item Price in Dollar<span style="font-weight:bold;">{{price | currency:"USD$"}}</span>
Item Price in Euro<span style="font-weight:bold;">{{price | currency:"&euro;"}}</span>

그리고 INR의 경우 문자 코드 Link2가 됩니다.

Item Price in Ruppese<span style="font-weight:bold;">{{price | currency:"&#8377;"}}</span>

"&#8377;"어느 정도", "어느 정도"의 입니다.

다이내믹하게 하고 싶은 경우는, 다음과 같이 해결합니다.

HTML

<div>{{ 100 | currencySymbol: 'USD' }}</div>

필터

angular.filter('currencySymbol', function ($filter) {
    return function(amount, currency) {
        return $filter('currency')(amount, currency_symbols[currency]);
    }
});

Javascript 통화 배열

var currency_symbols = {
    'USD': '$', // US Dollar
    'EUR': '€', // Euro
    'GBP': '£', // British Pound Sterling
    'ILS': '₪', // Israeli New Sheqel
    'INR': '₹', // Indian Rupee
    'JPY': '¥', // Japanese Yen
    'KRW': '₩', // South Korean Won
    'NGN': '₦', // Nigerian Naira
    'PHP': '₱', // Philippine Peso
    'PLN': 'zł', // Polish Zloty
    'PYG': '₲', // Paraguayan Guarani
    'THB': '฿', // Thai Baht
    'UAH': '₴', // Ukrainian Hryvnia
    'VND': '₫', // Vietnamese Dong
};

참조: http://docs.angularjs.org/api/ng.filter:currency

심플한 기능

currency:"USD$"

USD$ 대신 원하는 것을 사용할 수 있습니다.

통화 파이프에는 3개의 매개 변수가 있습니다.

코드1. 통화코드를 희망합니다.

.

값.2 통화기호의 표시 여부를 나타내는 부울값.

.

3. 정보 : 최소 , 및 됩니다.3 . 숫자 정보 (3부분 포함) : 최소 정수 자릿수, 최소 소수 자릿수 및 최대 소수 자릿수로 구성됩니다.
<span>{{value| currency:'1':2:'3'}}</span>

<span>{{9.667| currency:'USD':true:'2.2-3'}}</span>

산출량

$09.667

상세한 것에 대하여는, https://angular.io/api/common/CurrencyPipe 를 참조해 주세요.

통화 코드의 경우: https://en.wikipedia.org/wiki/ISO_4217

코드 사용하다INR

<span>{{100| currency:'INR':true}}</span>

산출량

₹100.00

언급URL : https://stackoverflow.com/questions/18612212/how-to-get-specific-currency-symbolrupee-symbol-in-my-case-in-angular-js-inste

반응형