本文整理匯總了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);
});
}