本文整理匯總了TypeScript中@angular/core.Compiler類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Compiler類的具體用法?TypeScript Compiler怎麽用?TypeScript Compiler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Compiler類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: ViewMetadata
it('should not update existing compilation results', () => {
viewResolver.setView(
SomeComp,
new ViewMetadata({template: '<child-cmp></child-cmp>', directives: [ChildComp]}));
viewResolver.setInlineTemplate(ChildComp, 'oldChild');
let compFactory = compiler.compileComponentSync(SomeComp);
viewResolver.setInlineTemplate(ChildComp, 'newChild');
compiler.compileComponentSync(SomeComp);
let compRef = compFactory.create(injector);
expect(compRef.location.nativeElement).toHaveText('oldChild');
});
示例2: fakeAsync
fakeAsync(() => {
@NgModule(
{declarations: [SomeCompWithUrlTemplate], precompile: [SomeCompWithUrlTemplate]})
class SomeModule {
}
xhr.spy('get').andCallFake(() => Promise.resolve('hello'));
compiler.compileModuleAsync(SomeModule);
tick();
let ngModuleFactory = compiler.compileModuleSync(SomeModule);
expect(ngModuleFactory).toBeTruthy();
}));
示例3: fakeAsync
fakeAsync(() => {
@NgModule({
declarations: [SomeCompWithUrlTemplate],
entryComponents: [SomeCompWithUrlTemplate]
})
class SomeModule {
}
resourceLoader.spy('get').and.callFake(() => Promise.resolve('hello'));
compiler.compileModuleAsync(SomeModule);
tick();
const ngModuleFactory = compiler.compileModuleSync(SomeModule);
expect(ngModuleFactory).toBeTruthy();
}));
示例4: resolve
return new Promise<NgModuleFactory<{}>>((resolve, reject) => {
// If module has been compiled AoT
if (moduleOrFactory instanceof NgModuleFactory) {
console.log('Already AoT?');
resolve(moduleOrFactory);
return;
} else {
let moduleFactory = factoryCacheMap.get(moduleOrFactory);
// If module factory is cached
if (moduleFactory) {
console.log('\n\n\n WE FOUND ONE!! USE IT!!\n\n\n');
resolve(moduleFactory);
return;
}
// Compile the module and cache it
compiler.compileModuleAsync(moduleOrFactory)
.then((factory) => {
console.log('\n\n\n\n MAP THIS THING!!!!\n\n\n ');
factoryCacheMap.set(moduleOrFactory, factory);
resolve(factory);
}, (err => {
reject(err);
}));
}
});
示例5: Error
.then((rawModule: any) => {
const module = rawModule[ngModuleExport];
if (!module) {
throw new Error(`Module ${modulePath} does not export ${ngModuleExport}`);
}
return compiler.compileModuleAsync(module);
});
示例6:
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);
});
});
示例7: of
return mergeMap.call(wrapIntoObservable(loadChildren()), (t: any) => {
if (t instanceof NgModuleFactory) {
return of (t);
} else {
return fromPromise(this.compiler.compileModuleAsync(t));
}
});
示例8: fakeAsync
fakeAsync(() => {
xhr.spy('get').andCallFake(() => Promise.resolve('hello'));
tcb.createFakeAsync(SomeCompWithUrlTemplate);
let appModuleFactory = compiler.compileAppModuleSync(
SomeModule, new AppModuleMetadata({precompile: [SomeCompWithUrlTemplate]}));
expect(appModuleFactory).toBeTruthy();
}));
示例9: wrapIntoObservable
return wrapIntoObservable(loadChildren()).pipe(mergeMap((t: any) => {
if (t instanceof NgModuleFactory) {
return of (t);
} else {
return from(this.compiler.compileModuleAsync(t));
}
}));
示例10: it
it('should allow to use templateUrl components', fakeAsync(() => {
xhr.spy('get').andCallFake(() => Promise.resolve('hello'));
let appModuleFactory: AppModuleFactory<any>;
compiler
.compileAppModuleAsync(
SomeModule, new AppModuleMetadata({precompile: [SomeCompWithUrlTemplate]}))
.then((f) => appModuleFactory = f);
tick();
expect(appModuleFactory.moduleType).toBe(SomeModule);
}));