本文整理汇总了TypeScript中@angular/compiler.StaticReflector.parameters方法的典型用法代码示例。如果您正苦于以下问题:TypeScript StaticReflector.parameters方法的具体用法?TypeScript StaticReflector.parameters怎么用?TypeScript StaticReflector.parameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/compiler.StaticReflector
的用法示例。
在下文中一共展示了StaticReflector.parameters方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should inherit parameters', () => {
initWithDecorator({
'/tmp/src/main.ts': `
import {ParamDecorator} from './decorator';
export class A {}
export class B {}
export class C {}
export class Parent {
constructor(@ParamDecorator('a') a: A, @ParamDecorator('b') b: B) {}
}
export class Child extends Parent {}
export class ChildWithCtor extends Parent {
constructor(@ParamDecorator('c') c: C) {}
}
export class ChildInvalidParent extends a.InvalidParent {}
`
});
// Check that metadata for Parent was not changed!
expect(reflector.parameters(reflector.getStaticSymbol('/tmp/src/main.ts', 'Parent')))
.toEqual([
[reflector.getStaticSymbol('/tmp/src/main.ts', 'A'), new ParamDecorator('a')],
[reflector.getStaticSymbol('/tmp/src/main.ts', 'B'), new ParamDecorator('b')]
]);
expect(reflector.parameters(reflector.getStaticSymbol('/tmp/src/main.ts', 'Child'))).toEqual([
[reflector.getStaticSymbol('/tmp/src/main.ts', 'A'), new ParamDecorator('a')],
[reflector.getStaticSymbol('/tmp/src/main.ts', 'B'), new ParamDecorator('b')]
]);
expect(reflector.parameters(reflector.getStaticSymbol('/tmp/src/main.ts', 'ChildWithCtor')))
.toEqual([[reflector.getStaticSymbol('/tmp/src/main.ts', 'C'), new ParamDecorator('c')]]);
expect(
reflector.parameters(reflector.getStaticSymbol('/tmp/src/main.ts', 'ChildInvalidParent')))
.toEqual([]);
});
示例2: it
it('should get constructor for NgFor', () => {
const NgFor = reflector.findDeclaration('@angular/common/src/directives/ng_for', 'NgFor');
const ViewContainerRef = reflector.findDeclaration('@angular/core', 'ViewContainerRef');
const TemplateRef = reflector.findDeclaration('@angular/core', 'TemplateRef');
const IterableDiffers = reflector.findDeclaration('@angular/core', 'IterableDiffers');
const ChangeDetectorRef = reflector.findDeclaration('@angular/core', 'ChangeDetectorRef');
const parameters = reflector.parameters(NgFor);
expect(parameters).toEqual([
[ViewContainerRef], [TemplateRef], [IterableDiffers], [ChangeDetectorRef]
]);
});
示例3: it
it('should be able to inject a ctor parameter with a @Inject and a type expression', () => {
const data = Object.create(DEFAULT_TEST_DATA);
const file = '/tmp/src/invalid-component.ts';
data[file] = `
import {Injectable, Inject} from '@angular/core';
@Injectable()
export class SomeClass {
constructor (@Inject('some-token') a: {a: string, b: string}) {}
}
`;
init(data);
const someClass = reflector.getStaticSymbol(file, 'SomeClass');
const parameters = reflector.parameters(someClass);
expect(compilerCore.createInject.isTypeOf(parameters[0][0])).toBe(true);
});