Пример #1
0
 ComponentDecoratorHandler.prototype.compile = function (node, analysis, pool) {
     // Check whether this component was registered with an NgModule. If so, it should be compiled
     // under that module's compilation scope.
     var scope = this.scopeRegistry.lookupCompilationScope(node);
     var metadata = analysis.meta;
     if (scope !== null) {
         // Replace the empty components and directives from the analyze() step with a fully expanded
         // scope. This is possible now because during compile() the whole compilation unit has been
         // fully analyzed.
         var pipes = scope.pipes, containsForwardDecls = scope.containsForwardDecls;
         var directives_1 = new Map();
         scope.directives.forEach(function (meta, selector) { return directives_1.set(selector, meta.directive); });
         var wrapDirectivesInClosure = !!containsForwardDecls;
         metadata = tslib_1.__assign({}, metadata, { directives: directives_1, pipes: pipes, wrapDirectivesInClosure: wrapDirectivesInClosure });
     }
     var res = compiler_1.compileComponentFromMetadata(metadata, pool, compiler_1.makeBindingParser());
     return {
         name: 'ngComponentDef',
         initializer: res.expression,
         statements: res.statements,
         type: res.type,
     };
 };
Пример #2
0
 ComponentDecoratorHandler.prototype.compile = function (node, analysis) {
     var pool = new compiler_1.ConstantPool();
     // Check whether this component was registered with an NgModule. If so, it should be compiled
     // under that module's compilation scope.
     var scope = this.scopeRegistry.lookupCompilationScope(node);
     if (scope !== null) {
         // Replace the empty components and directives from the analyze() step with a fully expanded
         // scope. This is possible now because during compile() the whole compilation unit has been
         // fully analyzed.
         analysis = tslib_1.__assign({}, analysis, scope);
     }
     var res = compiler_1.compileComponentFromMetadata(analysis, pool, compiler_1.makeBindingParser());
     return {
         name: 'ngComponentDef',
         initializer: res.expression,
         statements: pool.statements,
         type: res.type,
     };
 };