當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。