当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript StringWrapper.startsWith方法代码示例

本文整理汇总了TypeScript中angular2/src/facade/lang.StringWrapper.startsWith方法的典型用法代码示例。如果您正苦于以下问题:TypeScript StringWrapper.startsWith方法的具体用法?TypeScript StringWrapper.startsWith怎么用?TypeScript StringWrapper.startsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angular2/src/facade/lang.StringWrapper的用法示例。


在下文中一共展示了StringWrapper.startsWith方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: setterFactory

export function setterFactory(property: string): Function {
  var setterFn, styleParts, styleSuffix;
  if (StringWrapper.startsWith(property, ATTRIBUTE_PREFIX)) {
    setterFn = attributeSetterFactory(StringWrapper.substring(property, ATTRIBUTE_PREFIX.length));
  } else if (StringWrapper.startsWith(property, CLASS_PREFIX)) {
    setterFn = classSetterFactory(StringWrapper.substring(property, CLASS_PREFIX.length));
  } else if (StringWrapper.startsWith(property, STYLE_PREFIX)) {
    styleParts = property.split(STYLE_SEPARATOR);
    styleSuffix = styleParts.length > 2 ? ListWrapper.get(styleParts, 2) : '';
    setterFn = styleSetterFactory(ListWrapper.get(styleParts, 1), styleSuffix);
  } else if (StringWrapper.equals(property, 'innerHtml')) {
    if (isBlank(innerHTMLSetterCache)) {
      innerHTMLSetterCache = (el, value) => DOM.setInnerHTML(el, value);
    }
    setterFn = innerHTMLSetterCache;
  } else {
    property = resolvePropertyName(property);
    setterFn = StringMapWrapper.get(propertySettersCache, property);
    if (isBlank(setterFn)) {
      var propertySetterFn = reflector.setter(property);
      setterFn = function(receiver, value) {
        if (DOM.hasProperty(receiver, property)) {
          return propertySetterFn(receiver, value);
        }
      };
      StringMapWrapper.set(propertySettersCache, property, setterFn);
    }
  }
  return setterFn;
}
开发者ID:188799958,项目名称:angular,代码行数:30,代码来源:property_setter_factory.ts

示例2: if

 MapWrapper.forEach(this.redirects, (target, path) => {
   // "/" redirect case
   if (path == '/' || path == '') {
     if (path == url) {
       url = target;
     }
   } else if (StringWrapper.startsWith(url, path)) {
     url = target + StringWrapper.substring(url, path.length);
   }
 });
开发者ID:adrianojdesouza,项目名称:angular,代码行数:10,代码来源:route_recognizer.ts

示例3: BaseException

 MapWrapper.forEach(attrs, (attrValue, attrName) => {
   if (StringWrapper.startsWith(attrName, '*')) {
     var key = StringWrapper.substring(attrName, 1);
     if (hasTemplateBinding) {
       throw new BaseException(`Only one template directive per element is allowed: ` + `${templateBindings} and ${key} cannot be used simultaneously ` + `in ${current.elementDescription}`);
     } else {
       templateBindings = (attrValue.length == 0) ? key : key + ' ' + attrValue;
       hasTemplateBinding = true;
     }
   }
 });
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:11,代码来源:view_splitter.ts

示例4: _normalizeAttributeName

 _normalizeAttributeName(attrName: string): string {
   return StringWrapper.startsWith(attrName, 'data-') ? StringWrapper.substring(attrName, 5) :
                                                        attrName;
 }
开发者ID:goderbauer,项目名称:angular,代码行数:4,代码来源:property_binding_parser.ts

示例5: _addBaseHref

 _addBaseHref(url: string): string {
   if (!StringWrapper.startsWith(url, this._baseHref)) {
     return this._baseHref + url;
   }
   return url;
 }
开发者ID:B-Thapa,项目名称:angular,代码行数:6,代码来源:location.ts

示例6: _stripBaseHref

 _stripBaseHref(url: string): string {
   if (this._baseHref.length > 0 && StringWrapper.startsWith(url, this._baseHref)) {
     return StringWrapper.substring(url, this._baseHref.length);
   }
   return url;
 }
开发者ID:B-Thapa,项目名称:angular,代码行数:6,代码来源:location.ts

示例7:

 MapWrapper.forEach(this.redirects, (target, path) => {
   // TODO: "/" redirect case
   if (StringWrapper.startsWith(url, path)) {
     url = target + StringWrapper.substring(url, path.length);
   }
 });
开发者ID:B-Thapa,项目名称:angular,代码行数:6,代码来源:route_recognizer.ts


注:本文中的angular2/src/facade/lang.StringWrapper.startsWith方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。