当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Compiler.compileModuleAndAllComponentsAsync方法代码示例

本文整理汇总了TypeScript中@angular/core.Compiler.compileModuleAndAllComponentsAsync方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Compiler.compileModuleAndAllComponentsAsync方法的具体用法?TypeScript Compiler.compileModuleAndAllComponentsAsync怎么用?TypeScript Compiler.compileModuleAndAllComponentsAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular/core.Compiler的用法示例。


在下文中一共展示了Compiler.compileModuleAndAllComponentsAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

 System.import('./dist/lazy.bundle.js').then((module: any) => {
   this.compiler.compileModuleAndAllComponentsAsync(module.LazyModule)
     .then((compiled) => {
       const factory = compiled.componentFactories[0];
       this.container.createComponent(factory);
     });
 });
开发者ID:BobChao87,项目名称:angular,代码行数:7,代码来源:app.component.ts

示例2: createComponentFactory

export function createComponentFactory(compiler: Compiler,
                                       metadata: Component):
                                              Promise<ComponentFactory<any>> {
    const cmpClass = class DynamicComponent {};
    const decoratedCmp = Component(metadata)(cmpClass);

    @NgModule({ 
        imports: [ CommonModule ], 
        declarations: [decoratedCmp],
        schemas: [ CUSTOM_ELEMENTS_SCHEMA ] })
    class DynamicHtmlModule { }

    return compiler.compileModuleAndAllComponentsAsync(DynamicHtmlModule)
       .then((moduleWithComponentFactory: ModuleWithComponentFactories<any>) => 
                {
                    return moduleWithComponentFactory.componentFactories.find
                                ((x) => x.componentType === decoratedCmp);
                });
}
开发者ID:brakmic,项目名称:Angular_VRDemo,代码行数:19,代码来源:component-factory.ts

示例3: createComponentFactory

    /**
     * Use the runtime compiler to create this Component Factory dynamically as well as a dynamic module 
     * to wrapp it
     * 
     * This will create a dynamic module and a dynamic component by calling  compiler.compileModuleAndAllComponentsAsync and passing in a NgModule
     * that we create on the fly wrapping our newly created component
     * 
     * @param {Object} decoratorData
     * The medatata for this component we got from typedoc
     * 
     * @param {Function} cb
     * The callback to call when we create the component returning inside our component Factor
     * 
     * With this Component Factory we can then inject it in the View by using ViewContainerRef and Injector
     * See @dynamicOutlot.component.ts
     */
    createComponentFactory(decoratorData: Object, cb: Function) {

        // first get our metadata
        let metadata = this.createMetadata(decoratorData);
        let factory;

        const cmpClass = class DynamicComponent { };
        const decoratedCmp = Component(metadata)(cmpClass);

        @NgModule({
            imports: [BrowserModule],
            declarations: [decoratedCmp]
        })
        class DynamicModule { }

        this.compiler.compileModuleAndAllComponentsAsync(DynamicModule).then((moduleWithComponentFactory) => {
            const compFactory = moduleWithComponentFactory.componentFactories
                .find(x => x.componentType === decoratedCmp);
            cb(compFactory);
        });
    }
开发者ID:joaogarin,项目名称:carte-blanche-angular2,代码行数:37,代码来源:componentGenerator.service.ts


注:本文中的@angular/core.Compiler.compileModuleAndAllComponentsAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。