我想要一个有角度的货币管道以这种方式将数字转录为czk货币:
管道还应确保数字之间的空格永远不会导致数字之间换行,例如插入不间断空格。我保证没有小数。
我该怎么做?
确保导入正确的文件。
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>