如何使用CZK货币的角管?

问题描述 投票:0回答:1

我想要一个有角度的货币管道以这种方式将数字转录为czk货币:

  • 1000 => 1 000 Kč
  • 3141592653589 => 3 141 592 653 589 Kč
  • 4 => 4 Kč

管道还应确保数字之间的空格永远不会导致数字之间换行,例如插入不间断空格。我保证没有小数。

我该怎么做?

angular pipe currency-pipe
1个回答
0
投票

确保导入正确的文件。

TS文件:

import { Component, LOCALE_ID } from '@angular/core';
import { registerLocaleData } from '@angular/common';
import localeCs from '@angular/common/locales/cs'; // Import the Czech locale

@Component({
  selector: 'app-currency-example',
  templateUrl: './currency-example.component.html',
  providers: [
    { provide: LOCALE_ID, useValue: 'cs-CZ' } // Set the Czech locale
  ]
})
export class CurrencyExampleComponent {
  amount: number = 12345.67;
  
  constructor() {
    registerLocaleData(localeCs); // Register the Czech locale data
  }
}

HTML:

<div>
  <p>Formatted CZK: {{ amount | currency: 'CZK':'symbol':'1.0-0' }}</p>
</div>
© www.soinside.com 2019 - 2024. All rights reserved.