feat(core): expose inputs, outputs and ngContentSelectors on ComponentFactory.

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:
Tobias Bosch
2017-03-14 14:54:36 -07:00
committed by Chuck Jazdzewski
parent 8e2c8b3e4d
commit 1171f91a80
9 changed files with 134 additions and 11 deletions

View File

@ -162,12 +162,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(