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


TypeScript StringWrapper.substring方法代码示例

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


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

示例1: stripIndexHtml

function stripIndexHtml(url: string): string {
  // '/index.html'.length == 11
  if (url.length > 10 && StringWrapper.substring(url, url.length - 11) == '/index.html') {
    return StringWrapper.substring(url, 0, url.length - 11);
  }
  return url;
}
开发者ID:CADBOT,项目名称:angular,代码行数:7,代码来源:location.ts

示例2: 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

示例3: parse

 static parse(eventConfig: string): EventConfig {
   var fieldName = eventConfig, eventName = eventConfig, isLongForm = false;
   var separatorIdx = eventConfig.indexOf(EVENT_TARGET_SEPARATOR);
   if (separatorIdx > -1) {
     // long format: 'fieldName: eventName'
     fieldName = StringWrapper.substring(eventConfig, 0, separatorIdx).trim();
     eventName = StringWrapper.substring(eventConfig, separatorIdx + 1).trim();
     isLongForm = true;
   }
   return new EventConfig(fieldName, eventName, isLongForm);
 }
开发者ID:KenWilliamson,项目名称:Angular2HostedMobileApp,代码行数:11,代码来源:util.ts

示例4: addEventListener

 addEventListener(element, eventName, handler) {
   var shouldSupportBubble = eventName[0] == BUBBLE_SYMBOL;
   if (shouldSupportBubble) {
     eventName = StringWrapper.substring(eventName, 1);
   }
   var plugin = this._findPluginFor(eventName);
   plugin.addEventListener(element, eventName, handler, shouldSupportBubble);
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:8,代码来源:event_manager.ts

示例5: 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

示例6: 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

示例7: _bindDirectiveProperty

  _bindDirectiveProperty(bindConfig: string, compileElement: CompileElement,
                         directiveBinderBuilder: DirectiveBuilder) {
    // Name of the property on the directive
    let dirProperty: string;
    // Name of the property on the element
    let elProp: string;
    let pipes: List<string>;
    let assignIndex: number = bindConfig.indexOf(':');

    if (assignIndex > -1) {
      // canonical syntax: `dirProp: elProp | pipe0 | ... | pipeN`
      dirProperty = StringWrapper.substring(bindConfig, 0, assignIndex).trim();
      pipes = this._splitBindConfig(StringWrapper.substring(bindConfig, assignIndex + 1));
      elProp = ListWrapper.removeAt(pipes, 0);
    } else {
      // shorthand syntax when the name of the property on the directive and on the element is the
      // same, ie `property`
      dirProperty = bindConfig;
      elProp = bindConfig;
      pipes = [];
    }

    var bindingAst =
        MapWrapper.get(compileElement.bindElement().propertyBindings, dashCaseToCamelCase(elProp));

    if (isBlank(bindingAst)) {
      var attributeValue = MapWrapper.get(compileElement.attrs(), camelCaseToDashCase(elProp));
      if (isPresent(attributeValue)) {
        bindingAst =
            this._parser.wrapLiteralPrimitive(attributeValue, compileElement.elementDescription);
      }
    }

    // Bindings are optional, so this binding only needs to be set up if an expression is given.
    if (isPresent(bindingAst)) {
      var fullExpAstWithBindPipes = this._parser.addPipes(bindingAst, pipes);
      directiveBinderBuilder.bindProperty(dirProperty, fullExpAstWithBindPipes);
    }
  }
开发者ID:B-Thapa,项目名称:angular,代码行数:39,代码来源:directive_parser.ts

示例8: parseParams

  parseParams(url: string): StringMap<string, string> {
    var params = StringMapWrapper.create();
    var urlPart = url;
    for (var i = 0; i < this.segments.length; i++) {
      var segment = this.segments[i];
      var match = RegExpWrapper.firstMatch(RegExpWrapper.create('/' + segment.regex), urlPart);
      urlPart = StringWrapper.substring(urlPart, match[0].length);
      if (segment.name.length > 0) {
        StringMapWrapper.set(params, segment.name, match[1]);
      }
    }

    return params;
  }
开发者ID:AsherBarak,项目名称:angular,代码行数:14,代码来源:path_recognizer.ts

示例9: transform

 transform(value, args: List<any> = null): any {
   if (isBlank(args) || args.length == 0) {
     throw new BaseException('limitTo pipe requires one argument');
   }
   var limit: int = args[0];
   var left = 0, right = Math.min(limit, value.length);
   if (limit < 0) {
     left = Math.max(0, value.length + limit);
     right = value.length;
   }
   if (isString(value)) {
     return StringWrapper.substring(value, left, right);
   }
   return ListWrapper.slice(value, left, right);
 }
开发者ID:cedriclam,项目名称:angular,代码行数:15,代码来源:limit_to_pipe.ts

示例10: RouteMatch

 MapWrapper.forEach(this.matchers, (pathRecognizer, regex) => {
   var match;
   if (isPresent(match = RegExpWrapper.firstMatch(regex, url))) {
     // TODO(btford): determine a good generic way to deal with terminal matches
     var matchedUrl = '/';
     var unmatchedUrl = '';
     if (url != '/') {
       matchedUrl = match[0];
       unmatchedUrl = StringWrapper.substring(url, match[0].length);
     }
     solutions.push(new RouteMatch({
       specificity: pathRecognizer.specificity,
       handler: pathRecognizer.handler,
       params: pathRecognizer.parseParams(url),
       matchedUrl: matchedUrl,
       unmatchedUrl: unmatchedUrl
     }));
   }
 });
开发者ID:adrianojdesouza,项目名称:angular,代码行数:19,代码来源:route_recognizer.ts


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