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


TypeScript lang.isType函数代码示例

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


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

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

示例2: assertTerminalComponent

function assertTerminalComponent(component, path) {
  if (!isType(component)) {
    return;
  }

  var annotations = reflector.annotations(component);
  if (isPresent(annotations)) {
    for (var i = 0; i < annotations.length; i++) {
      var annotation = annotations[i];

      if (annotation instanceof RouteConfig) {
        throw new BaseException(
            `Child routes are not allowed for "${path}". Use "..." on the parent's route path.`);
      }
    }
  }
}
开发者ID:Salim-K,项目名称:angular,代码行数:17,代码来源:route_registry.ts

示例3: configFromComponent

  /**
   * Reads the annotations of a component and configures the registry based on them
   */
  configFromComponent(component): void {
    if (!isType(component)) {
      return;
    }

    // Don't read the annotations from a type more than once –
    // this prevents an infinite loop if a component routes recursively.
    if (MapWrapper.contains(this._rules, component)) {
      return;
    }
    var annotations = reflector.annotations(component);
    if (isPresent(annotations)) {
      for (var i = 0; i < annotations.length; i++) {
        var annotation = annotations[i];

        if (annotation instanceof RouteConfig) {
          ListWrapper.forEach(annotation.configs, (config) => this.config(component, config));
        }
      }
    }
  }
开发者ID:Mariem-07,项目名称:angular,代码行数:24,代码来源:route_registry.ts


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