本文整理汇总了TypeScript中@angular/core.NgModuleFactoryLoader类的典型用法代码示例。如果您正苦于以下问题:TypeScript NgModuleFactoryLoader类的具体用法?TypeScript NgModuleFactoryLoader怎么用?TypeScript NgModuleFactoryLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NgModuleFactoryLoader类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: fromPromise
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);
}));
}
示例2: openModal
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 }
});
});
}
示例3: loadModuleFactory
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));
}
}));
}
}
示例4: load
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);
});
}