diff --git a/src/core/compile/components/compile-html/compile-html.ts b/src/core/compile/components/compile-html/compile-html.ts index 683cd7043..fd7b82ec9 100644 --- a/src/core/compile/components/compile-html/compile-html.ts +++ b/src/core/compile/components/compile-html/compile-html.ts @@ -102,6 +102,10 @@ export class CoreCompileHtmlComponent implements OnChanges, OnDestroy, DoCheck { this.created.emit(this.componentRef.instance); } + this.loaded = true; + }).catch((error) => { + this.domUtils.showErrorModal(error); + this.loaded = true; }); } diff --git a/src/core/compile/providers/compile.ts b/src/core/compile/providers/compile.ts index 869b5a421..a17d62a8a 100644 --- a/src/core/compile/providers/compile.ts +++ b/src/core/compile/providers/compile.ts @@ -170,16 +170,20 @@ export class CoreCompileProvider { // Now create the module containing the component. const module = NgModule({imports: imports, declarations: [component]})(class {}); - // Compile the module and the component. - return this.compiler.compileModuleAndAllComponentsAsync(module).then((factories) => { - // Search and return the factory of the component we just created. - for (const i in factories.componentFactories) { - const factory = factories.componentFactories[i]; - if (factory.componentType == component) { - return factory; + try { + // Compile the module and the component. + return this.compiler.compileModuleAndAllComponentsAsync(module).then((factories) => { + // Search and return the factory of the component we just created. + for (const i in factories.componentFactories) { + const factory = factories.componentFactories[i]; + if (factory.componentType == component) { + return factory; + } } - } - }); + }); + } catch (ex) { + return Promise.reject({message: 'Template has some errors and cannot be displayed.', debuginfo: ex}); + } } /**