1
- import { Component } from '@angular/core' ;
1
+ import { Component , computed , signal } from '@angular/core' ;
2
2
import { FormsModule } from '@angular/forms' ;
3
3
import { MatOptionModule } from '@angular/material/core' ;
4
4
import { MatFormFieldModule } from '@angular/material/form-field' ;
5
5
import { MatInputModule } from '@angular/material/input' ;
6
6
import { MatSelectModule } from '@angular/material/select' ;
7
- import { IntlCurrencyPipe } from '../../../../../angular-ecmascript-intl/src/lib/currency/intl-currency.pipe' ;
7
+ import {
8
+ IntlCurrencyPipe ,
9
+ IntlCurrencyPipeOptions ,
10
+ } from 'angular-ecmascript-intl' ;
8
11
import { languages } from '../../languages' ;
9
12
import { currencies } from './currencies' ;
10
13
@@ -22,28 +25,41 @@ import { currencies } from './currencies';
22
25
] ,
23
26
} )
24
27
export class CurrencyComponent {
25
- enteredNumber = '0.24' ;
26
- currency = 'USD' ;
28
+ enteredNumber = signal ( '0.24' ) ;
29
+ currency = signal ( 'USD' ) ;
27
30
languages = languages ;
28
31
currencies = currencies ;
29
- locale ?: string ;
30
- notation ?: Intl . NumberFormatOptions [ 'notation' ] ;
31
- signDisplay ?: Intl . NumberFormatOptions [ 'signDisplay' ] ;
32
- currencyDisplay ?: Intl . NumberFormatOptions [ 'currencyDisplay' ] ;
33
- currencySign ?: Intl . NumberFormatOptions [ 'currencySign' ] ;
34
- minimumIntegerDigits ?:
35
- | Intl . NumberFormatOptions [ 'minimumIntegerDigits' ]
36
- | null ;
37
- minimumFractionDigits ?:
38
- | Intl . NumberFormatOptions [ 'minimumFractionDigits' ]
39
- | null ;
40
- maximumFractionDigits ?:
41
- | Intl . NumberFormatOptions [ 'maximumFractionDigits' ]
42
- | null ;
43
- minimumSignificantDigits ?:
44
- | Intl . NumberFormatOptions [ 'minimumSignificantDigits' ]
45
- | null ;
46
- maximumSignificantDigits ?:
47
- | Intl . NumberFormatOptions [ 'maximumSignificantDigits' ]
48
- | null ;
32
+ locale = signal < string | undefined > ( undefined ) ;
33
+ notation = signal < IntlCurrencyPipeOptions [ 'notation' ] > ( undefined ) ;
34
+ signDisplay = signal < IntlCurrencyPipeOptions [ 'signDisplay' ] > ( undefined ) ;
35
+ currencyDisplay =
36
+ signal < IntlCurrencyPipeOptions [ 'currencyDisplay' ] > ( undefined ) ;
37
+ currencySign = signal < IntlCurrencyPipeOptions [ 'currencySign' ] > ( undefined ) ;
38
+ minimumIntegerDigits = signal <
39
+ IntlCurrencyPipeOptions [ 'minimumIntegerDigits' ] | null
40
+ > ( undefined ) ;
41
+ minimumFractionDigits = signal <
42
+ IntlCurrencyPipeOptions [ 'minimumFractionDigits' ] | null
43
+ > ( undefined ) ;
44
+ maximumFractionDigits = signal <
45
+ IntlCurrencyPipeOptions [ 'maximumFractionDigits' ] | null
46
+ > ( undefined ) ;
47
+ minimumSignificantDigits = signal <
48
+ IntlCurrencyPipeOptions [ 'minimumSignificantDigits' ] | null
49
+ > ( undefined ) ;
50
+ maximumSignificantDigits = signal <
51
+ IntlCurrencyPipeOptions [ 'maximumSignificantDigits' ] | null
52
+ > ( undefined ) ;
53
+ options = computed < IntlCurrencyPipeOptions > ( ( ) => ( {
54
+ locale : this . locale ( ) ,
55
+ currencyDisplay : this . currencyDisplay ( ) ,
56
+ currencySign : this . currencySign ( ) ,
57
+ notation : this . notation ( ) ,
58
+ signDisplay : this . signDisplay ( ) ,
59
+ minimumIntegerDigits : this . minimumIntegerDigits ( ) ?? undefined ,
60
+ minimumFractionDigits : this . minimumFractionDigits ( ) ?? undefined ,
61
+ maximumFractionDigits : this . maximumFractionDigits ( ) ?? undefined ,
62
+ minimumSignificantDigits : this . minimumSignificantDigits ( ) ?? undefined ,
63
+ maximumSignificantDigits : this . maximumSignificantDigits ( ) ?? undefined ,
64
+ } ) ) ;
49
65
}
0 commit comments