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


TypeScript lang.isPresent函數代碼示例

本文整理匯總了TypeScript中@angular/common/src/facade/lang.isPresent函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isPresent函數的具體用法?TypeScript isPresent怎麽用?TypeScript isPresent使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: 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
    });

  }
開發者ID:MedAnd,項目名稱:angular2localization,代碼行數:41,代碼來源:locale-number.ts

示例2: validateEmail

export function validateEmail(control: Control) {
  let pattern: RegExp = /^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i

  if (isPresent(Validators.required(control))) {
    return null
  }

  return pattern.test(control.value) ? null : {
    nbEmail: {
      valid: false,
    },
  }
}
開發者ID:emesonsantana,項目名稱:bmp1-web-service,代碼行數:13,代碼來源:email.validator.ts

示例3: validateDate

export function validateDate(control: Control) {
  let pattern: RegExp = /^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$/g

  if (isPresent(Validators.required(control))) {
    return null
  }

  return pattern.test(control.value) ? null : {
    nbDate: {
      valid: false,
    },
  }
}
開發者ID:emesonsantana,項目名稱:bmp1-web-service,代碼行數:13,代碼來源:date.validator.ts

示例4: OneOfMetadata

   return function OneOfMetadata(target: any, key: string): void {
     const defaultValue = values[0];

     // Use a fallback if Symbol isn't available.
     const localKey = isPresent(Symbol) ? Symbol(key) : `@@$${key}_`;
     target[localKey] = defaultValue;

     Object.defineProperty(target, key, {
       get() { return this[localKey]; },
       set(v) {
         if (values.indexOf(v) === -1) {
           this[localKey] = defaultValue;
         } else {
           this[localKey] = v;
         }
       }
     });
   };
開發者ID:sargerasy,項目名稱:vuuvv,代碼行數:18,代碼來源:one-of.ts

示例5: parseTabIndexAttribute

export function parseTabIndexAttribute(attr: any): number {
  return isPresent(attr) ? NumberWrapper.parseInt(attr, 10) : 0;
}
開發者ID:robwafle,項目名稱:ng2-material,代碼行數:3,代碼來源:util.ts


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