feat(core): expose inputs
, outputs
and ngContentSelectors
on ComponentFactory
. (#15214)
E.g. for a component like this: ``` @Component({ template: ‘<ng-content select=“child”></ng-content>’ }) class MyComp { @Input(‘aInputName’) aInputProp: string; @Output(‘aEventName’) aOuputProp: EventEmitter<any>; } ``` the `ComponentFactory` will now contain the following: - `inputs = {aInputProp: ‘aInputName’}` - `outputs = {aOutputProp: ‘aOutputName’}` - `ngContentSelectors = [‘child’]`
This commit is contained in:

committed by
Miško Hevery

parent
604546c287
commit
791534f2f4
@ -163,12 +163,27 @@ export class AotCompiler {
|
||||
hostMeta, ngModule, [compMeta.type], null, fileSuffix, targetStatements)
|
||||
.viewClassVar;
|
||||
const compFactoryVar = componentFactoryName(compMeta.type.reference);
|
||||
const inputsExprs: o.LiteralMapEntry[] = [];
|
||||
for (let propName in compMeta.inputs) {
|
||||
const templateName = compMeta.inputs[propName];
|
||||
// Don't quote so that the key gets minified...
|
||||
inputsExprs.push(new o.LiteralMapEntry(propName, o.literal(templateName), false));
|
||||
}
|
||||
const outputsExprs: o.LiteralMapEntry[] = [];
|
||||
for (let propName in compMeta.outputs) {
|
||||
const templateName = compMeta.outputs[propName];
|
||||
// Don't quote so that the key gets minified...
|
||||
outputsExprs.push(new o.LiteralMapEntry(propName, o.literal(templateName), false));
|
||||
}
|
||||
|
||||
targetStatements.push(
|
||||
o.variable(compFactoryVar)
|
||||
.set(o.importExpr(createIdentifier(Identifiers.createComponentFactory)).callFn([
|
||||
o.literal(compMeta.selector),
|
||||
o.importExpr(compMeta.type),
|
||||
o.variable(hostViewFactoryVar),
|
||||
o.literal(compMeta.selector), o.importExpr(compMeta.type),
|
||||
o.variable(hostViewFactoryVar), new o.LiteralMapExpr(inputsExprs),
|
||||
new o.LiteralMapExpr(outputsExprs),
|
||||
o.literalArr(
|
||||
compMeta.template.ngContentSelectors.map(selector => o.literal(selector)))
|
||||
]))
|
||||
.toDeclStmt(
|
||||
o.importType(
|
||||
|
Reference in New Issue
Block a user