TypeScript @angular-core.NgModuleFactoryLoader类(方法)实例源码

下面列出了TypeScript @angular-core.NgModuleFactoryLoader 类(方法)源码代码实例,从而了解它的用法。

作者:AngularLover    项目:angula   
load(parentInjector: Injector, path: string): Observable<LoadedRouterConfig> {
   return fromPromise(this.loader.load(path).then(r => {
     const ref = r.create(parentInjector);
     return new LoadedRouterConfig(
         ref.injector.get(ROUTES), ref.injector, ref.componentFactoryResolver);
   }));
 }

作者:NativeScrip    项目:tests-app-n   
public openModal() {
        this.moduleLoader.load("./lazy/lazy.module#LazyModule")
            .then((module: NgModuleFactory<any>) => {
                const moduleRef = module.create(this.vcRef.parentInjector);

                this.modalService.showModal(LazyComponent, {
                    moduleRef,
                    viewContainerRef: this.vcRef,
                    context: { isModal: true }
                });
            });
    }

作者:Cammisul    项目:angula   
private loadModuleFactory(loadChildren: LoadChildren): Observable<NgModuleFactory<any>> {
   if (typeof loadChildren === 'string') {
     return from(this.loader.load(loadChildren));
   } else {
     return wrapIntoObservable(loadChildren()).pipe(mergeMap((t: any) => {
       if (t instanceof NgModuleFactory) {
         return of (t);
       } else {
         return from(this.compiler.compileModuleAsync(t));
       }
     }));
   }
 }

作者:yperri    项目:Experiment   
load(): Promise<void> {
        
        if (this.moduleRef) {
            return Promise.resolve();
        }

        const path = 'src/app/dashboard/lazy-dashboard-tile/lazy-dashboard-tile.module#LazyDashboardTileModule';
        
        return this
            .loader
            .load(path)
            .then(moduleFactory => {
                this.moduleRef = moduleFactory.create(this.injector).instance;
                console.debug('moduleRef', this.moduleRef);
            })
            .catch(err => {
                console.error('error loading module', err); 
            });
        
    }


问题


面经


文章

微信
公众号

扫码关注公众号