當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript CurrencyPipe.transform方法代碼示例

本文整理匯總了TypeScript中@angular/common.CurrencyPipe.transform方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript CurrencyPipe.transform方法的具體用法?TypeScript CurrencyPipe.transform怎麽用?TypeScript CurrencyPipe.transform使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@angular/common.CurrencyPipe的用法示例。


在下文中一共展示了CurrencyPipe.transform方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

 it('should support any currency code name', () => {
   // currency code is unknown, default formatting options will be used
   expect(pipe.transform(5.1234, 'unexisting_ISO_code', 'symbol'))
       .toEqual('unexisting_ISO_code5.12');
   // currency code is USD, the pipe will format based on USD but will display "Custom name"
   expect(pipe.transform(5.1234, 'USD', 'Custom name')).toEqual('Custom name5.12');
 });
開發者ID:IdeaBlade,項目名稱:angular,代碼行數:7,代碼來源:number_pipe_spec.ts

示例2: transform

    transform(value: number, ...args: any[]): any {
        let assetInfo = args.find(a => a instanceof Assets || a instanceof Object) as Assets;
        let currency = args.find(a => typeof a === "string") as string;
        let showCurrency = args.find(a => typeof a === "boolean");
        if (showCurrency === undefined) {
            showCurrency = true;
        }

        if (assetInfo && currency) {
            let asset = assetInfo[currency] ? assetInfo[currency] :
                (assetInfo['X' + currency] ? assetInfo['X' + currency] : null);
            //(assetInfo['Z' + currency] ? assetInfo['Z' + currency] : null));
            if (!asset && currency.startsWith('Z') && currency !== 'ZBT') {
                return this.currencyPipe.transform(value, currency.substring(1, currency.length), true);
            }
            else if (!asset) {
                return this.decimalPipe.transform(value, '1.5-5');
            }
            if (asset.assetClass === 'currency' && currency.startsWith('Z') && currency !== 'ZBT') {
                return this.currencyPipe.transform(value, currency.substring(1, currency.length), true);
            }
            let displayDecimals = asset.displayDecimals.toString();
            return this.decimalPipe.transform(value, '1.' + displayDecimals + '-' + displayDecimals);
        } else if (currency) {
            return this.currencyPipe.transform(value, currency.startsWith('Z') ? currency.substring(1, currency.length) : currency, true);
        }

        return this.decimalPipe.transform(value, '1.2-2');

    }
開發者ID:wallaceiam,項目名稱:mKraken,代碼行數:30,代碼來源:cryptocurrency.pipe.ts

示例3: it

 it('should return correct value for numbers', () => {
   // In old Chrome, default formatiing for USD is different
   if (browserDetection.isOldChrome) {
     expect(normalize(pipe.transform(123))).toEqual('USD123');
   } else {
     expect(normalize(pipe.transform(123))).toEqual('USD123.00');
   }
   expect(normalize(pipe.transform(12, 'EUR', false, '.1'))).toEqual('EUR12.0');
   expect(normalize(pipe.transform(5.1234, 'USD', false, '.0-3'))).toEqual('USD5.123');
 });
開發者ID:JanStureNielsen,項目名稱:angular,代碼行數:10,代碼來源:number_pipe_spec.ts

示例4: getLastVolumeTo

 getLastVolumeTo(): string {
   if (this.tickerData.TOSYMBOL == 'USD') {
     return this.currencyPipe.transform(this.tickerData.LASTVOLUMETO, this.tickerData.TOSYMBOL, true, '0.2-2');
     // return "tickerData.PRICE | currency:tickerData.TOSYMBOL:true"
   }
   else {
     let trade_pair_key: string = "USD_" + this.tickerData.TOSYMBOL;
     return this.currencyPipe.transform(this.tickerData.LASTVOLUMETO, this.tickerData.TOSYMBOL, true) + ' ( ' +
       this.currencyPipe.transform(this.tickerData.LASTVOLUMETO/this.cryptoCompareService.exchangeRates.get(trade_pair_key), 'USD', true, '0.2-2') + ' ) ';
   }
 }
開發者ID:funnyData,項目名稱:crypto-arb-tracker,代碼行數:11,代碼來源:trading-pair-card.component.ts

示例5: currencyFmt

 public currencyFmt( val) {
   console.log( val);
   let v = val.replace( /[^\d]/g,'');
   v = (+v)/100;
   console.log( v);
   let x = this.currencyPipe.transform(v, 'USD', true, '1.2-2' ); // this.accountNumberFormat(value);
   console.log( x);
   return x;
 }
開發者ID:dmostroff,項目名稱:ccpoints,代碼行數:9,代碼來源:utils.service.ts

示例6: constructor

    constructor(i18nService: I18nService, platformUtilsService: PlatformUtilsService,
        tokenService: TokenService, apiService: ApiService,
        private currencyPipe: CurrencyPipe) {
        super(i18nService, platformUtilsService, tokenService, apiService);

        // Support old price string. Can be removed in future once all translations are properly updated.
        const thePrice = this.currencyPipe.transform(this.price, '$');
        this.priceString = i18nService.t('premiumPrice', thePrice);
        if (this.priceString.indexOf('%price%') > -1) {
            this.priceString = this.priceString.replace('%price%', thePrice);
        }
    }
開發者ID:bitwarden,項目名稱:browser,代碼行數:12,代碼來源:premium.component.ts

示例7: expect

 () => { expect(() => pipe.transform(new Object())).toThrowError(); });
開發者ID:AngularLovers,項目名稱:angular,代碼行數:1,代碼來源:number_pipe_spec.ts

示例8: it

 it('should return correct value for numbers', () => {
   expect(pipe.transform(123)).toEqual('USD123.00');
   expect(pipe.transform(12, 'EUR', false, '.1')).toEqual('EUR12.0');
   expect(pipe.transform(5.1234, 'USD', false, '.0-3')).toEqual('USD5.123');
 });
開發者ID:AngularLovers,項目名稱:angular,代碼行數:5,代碼來源:number_pipe_spec.ts


注:本文中的@angular/common.CurrencyPipe.transform方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。