本文整理汇总了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)}`);
}
示例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;
}
示例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)}`);
}
示例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)}`);
}
示例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)}`);
}
示例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)}`);
}
示例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.`);
}
}
}
}
示例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));
}
}
}
}