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


TypeScript lang.isStringMap函数代码示例

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


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

示例1: _update

function _update(node: TreeNode<UrlSegment>, changes: any[]): TreeNode<UrlSegment> {
  let rest = changes.slice(1);
  let outlet = _outlet(changes);
  let segment = _segment(changes);
  if (isString(segment) && segment[0] == "/") segment = segment.substring(1);

  // reach the end of the tree => create new tree nodes.
  if (isBlank(node)) {
    let urlSegment = new UrlSegment(segment, null, outlet);
    let children = rest.length === 0 ? [] : [_update(null, rest)];
    return new TreeNode<UrlSegment>(urlSegment, children);

    // different outlet => preserve the subtree
  } else if (outlet != node.value.outlet) {
    return node;

    // same outlet => modify the subtree
  } else {
    let urlSegment = isStringMap(segment) ? new UrlSegment(null, segment, null) :
                                            new UrlSegment(segment, null, outlet);
    if (rest.length === 0) {
      return new TreeNode<UrlSegment>(urlSegment, []);
    }

    return new TreeNode<UrlSegment>(urlSegment,
                                    _updateMany(ListWrapper.clone(node.children), rest));
  }
}
开发者ID:JavaScript-Resource,项目名称:angular,代码行数:28,代码来源:link.ts

示例2: transform

  transform(value: string, mapping: {[key: string]: string}): string {
    if (!isStringMap(mapping)) {
      throw new InvalidPipeArgumentException(I18nSelectPipe, mapping);
    }

    return StringMapWrapper.contains(mapping, value) ? mapping[value] : mapping['other'];
  }
开发者ID:844496869,项目名称:angular,代码行数:7,代码来源:i18n_select_pipe.ts

示例3: transform

  transform(value: number, pluralMap: {[count: string]: string}): string {
    var key: string;
    var valueStr: string;

    if (!isStringMap(pluralMap)) {
      throw new InvalidPipeArgumentException(I18nPluralPipe, pluralMap);
    }

    key = value === 0 || value === 1 ? `=${value}` : 'other';
    valueStr = isPresent(value) ? value.toString() : '';

    return StringWrapper.replaceAll(pluralMap[key], interpolationExp, valueStr);
  }
开发者ID:844496869,项目名称:angular,代码行数:13,代码来源:i18n_plural_pipe.ts

示例4: normalizeComponentDeclaration

function normalizeComponentDeclaration(config: any): StringMap<string, any> {
  if (isType(config)) {
    return {'constructor': config, 'type': 'constructor'};
  } else if (isStringMap(config)) {
    if (isBlank(config['type'])) {
      throw new BaseException(
          `Component declaration when provided as a map should include a 'type' property`);
    }
    var componentType = config['type'];
    if (!ListWrapper.contains(VALID_COMPONENT_TYPES, componentType)) {
      throw new BaseException(`Invalid component type '${componentType}'`);
    }
    return config;
  } else {
    throw new BaseException(`Component declaration should be either a Map or a Type`);
  }
}
开发者ID:AsherBarak,项目名称:angular,代码行数:17,代码来源:route_registry.ts


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