本文整理汇总了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;
}