UNPKG

angular-l10n

Version:

An Angular library to translate messages, dates and numbers

59 lines 2.16 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc */ import { LocaleService } from '../services/locale.service'; import { InjectorRef } from '../models/injector-ref'; import { takeUntilDestroyed } from '../models/take-until-destroyed'; import { Logger } from '../models/logger'; /** * Property decorator for components to provide the parameter to the l10nCurrency pipe. * @return {?} */ export function Currency() { /** * @param {?} target * @param {?=} propertyKey * @return {?} */ function DecoratorFactory(target, propertyKey) { /** @type {?} */ var targetNgOnInit = target.ngOnInit; if (typeof targetNgOnInit === "undefined") { Logger.log(target.constructor ? target.constructor.name : 'Currency decorator', 'missingOnInit'); } /** * @this {?} * @return {?} */ function ngOnInit() { var _this = this; /** @type {?} */ var locale = InjectorRef.get(LocaleService); if (typeof propertyKey !== "undefined") { this[propertyKey] = locale.getCurrentCurrency(); locale.currencyCodeChanged.pipe(takeUntilDestroyed(this)).subscribe(function (currency) { _this[propertyKey] = currency; /** @type {?} */ var cdr = Object.keys(_this) .find(function (key) { return _this[key] && _this[key]['markForCheck'] !== undefined; }); if (cdr) { _this[cdr].markForCheck(); } }); } if (targetNgOnInit) { targetNgOnInit.apply(this); } } target.ngOnInit = ngOnInit; if (typeof propertyKey !== "undefined") { Object.defineProperty(target, propertyKey, { writable: true, value: '' }); } } return DecoratorFactory; } //# sourceMappingURL=currency.decorator.js.map