本文整理匯總了TypeScript中@angular/common/src/facade/lang.NumberWrapper類的典型用法代碼示例。如果您正苦於以下問題:TypeScript NumberWrapper類的具體用法?TypeScript NumberWrapper怎麽用?TypeScript NumberWrapper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了NumberWrapper類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: validate
return function validate(control: AbstractControl): {[key: string]: any} {
if (NumberWrapper.isNaN(control.value) || control.value <= length) {
return null;
}
return {
mdMax: true
};
}
示例2: format
static format(defaultLocale: string, value: number, style: NumberFormatStyle, digits: string, currency: string = null, currencyAsSymbol: boolean = false): string {
if (isBlank(value)) return null;
if (!isNumber(value)) {
throw new InvalidPipeArgumentException(LocaleNumber, value);
}
var minInt = 1, minFraction = 0, maxFraction = 3;
var re = RegExpWrapper.create('^(\\d+)?\\.((\\d+)(\\-(\\d+))?)?$');
if (isPresent(digits)) {
var parts = RegExpWrapper.firstMatch(re, digits);
if (isBlank(parts)) {
throw new BaseException(`${digits} is not a valid digit info for number pipes`);
}
if (isPresent(parts[1])) { // Min integer digits.
minInt = NumberWrapper.parseIntAutoRadix(parts[1]);
}
if (isPresent(parts[3])) { // Min fraction digits.
minFraction = NumberWrapper.parseIntAutoRadix(parts[3]);
}
if (isPresent(parts[5])) { // Max fraction digits.
maxFraction = NumberWrapper.parseIntAutoRadix(parts[5]);
}
}
return NumberFormatter.format(value, defaultLocale, style, {
minimumIntegerDigits: minInt,
minimumFractionDigits: minFraction,
maximumFractionDigits: maxFraction,
currency: currency,
currencyAsSymbol: currencyAsSymbol
});
}
示例3: parseTabIndexAttribute
export function parseTabIndexAttribute(attr: any): number {
return isPresent(attr) ? NumberWrapper.parseInt(attr, 10) : 0;
}