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


TypeScript reflector.annotations方法代码示例

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


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

示例1: _resolve

 _resolve(component) {
   var annotations = reflector.annotations(component);
   for (var i = 0; i < annotations.length; i++) {
     var annotation = annotations[i];
     if (annotation instanceof Template) {
       return annotation;
     }
   }
   throw new BaseException(`No template found for ${stringify(component)}`);
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:10,代码来源:template_resolver.ts

示例2: _resolve

 _resolve(component: Type) {
   var annotations = reflector.annotations(component);
   for (var i = 0; i < annotations.length; i++) {
     var annotation = annotations[i];
     if (annotation instanceof View) {
       return annotation;
     }
   }
   // No annotation = dynamic component!
   return null;
 }
开发者ID:188799958,项目名称:angular,代码行数:11,代码来源:template_resolver.ts

示例3: resolve

 /**
  * Return {@link DirectiveMetadata} for a given `Type`.
  */
 resolve(type: Type): DirectiveMetadata {
   var annotations = reflector.annotations(resolveForwardRef(type));
   if (isPresent(annotations)) {
     for (var i = 0; i < annotations.length; i++) {
       var annotation = annotations[i];
       if (annotation instanceof DirectiveMetadata) {
         return annotation;
       }
     }
   }
   throw new BaseException(`No Directive annotation found on ${stringify(type)}`);
 }
开发者ID:KenWilliamson,项目名称:Angular2HostedMobileApp,代码行数:15,代码来源:directive_resolver.ts

示例4: read

 read(type) {
   var annotations = reflector.annotations(type);
   if (isPresent(annotations)) {
     for (var i = 0; i < annotations.length; i++) {
       var annotation = annotations[i];
       if (annotation instanceof Directive) {
         return new DirectiveMetadata(type, annotation);
       }
     }
   }
   throw new BaseException(`No Directive annotation found on ${stringify(type)}`);
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:12,代码来源:directive_metadata_reader.ts

示例5: resolve

 /**
  * Return {@link Pipe} for a given `Type`.
  */
 resolve(type: Type): Pipe {
   var metas = reflector.annotations(resolveForwardRef(type));
   if (isPresent(metas)) {
     for (var i = 0; i < metas.length; i++) {
       var annotation = metas[i];
       if (annotation instanceof Pipe) {
         return annotation;
       }
     }
   }
   throw new BaseException(`No Pipe decorator found on ${stringify(type)}`);
 }
开发者ID:goderbauer,项目名称:angular,代码行数:15,代码来源:pipe_resolver.ts

示例6: read

  read(type:Type):DirectiveMetadata {
    var annotations = reflector.annotations(type);
    if (isPresent(annotations)) {
      for (var i=0; i<annotations.length; i++) {
        var annotation = annotations[i];

        if (annotation instanceof DirectiveAnnotation) {
          var resolvedInjectables = null;
          if (annotation instanceof ComponentAnnotation && isPresent(annotation.injectables)) {
            resolvedInjectables = Injector.resolve(annotation.injectables);
          }
          return new DirectiveMetadata(type, annotation, resolvedInjectables);
        }
      }
    }
    throw new BaseException(`No Directive annotation found on ${stringify(type)}`);
  }
开发者ID:tavwizard,项目名称:angular,代码行数:17,代码来源:directive_metadata_reader.ts

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

示例8: 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/reflection/reflection.reflector.annotations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。