MOBILE-2795 compile: Show error on template parsing

main
Pau Ferrer Ocaña 2019-01-11 08:55:33 +01:00
parent 953c5ab0a4
commit 65d048c494
2 changed files with 17 additions and 9 deletions

View File

@ -102,6 +102,10 @@ export class CoreCompileHtmlComponent implements OnChanges, OnDestroy, DoCheck {
this.created.emit(this.componentRef.instance); this.created.emit(this.componentRef.instance);
} }
this.loaded = true;
}).catch((error) => {
this.domUtils.showErrorModal(error);
this.loaded = true; this.loaded = true;
}); });
} }

View File

@ -170,16 +170,20 @@ export class CoreCompileProvider {
// Now create the module containing the component. // Now create the module containing the component.
const module = NgModule({imports: imports, declarations: [component]})(class {}); const module = NgModule({imports: imports, declarations: [component]})(class {});
// Compile the module and the component. try {
return this.compiler.compileModuleAndAllComponentsAsync(module).then((factories) => { // Compile the module and the component.
// Search and return the factory of the component we just created. return this.compiler.compileModuleAndAllComponentsAsync(module).then((factories) => {
for (const i in factories.componentFactories) { // Search and return the factory of the component we just created.
const factory = factories.componentFactories[i]; for (const i in factories.componentFactories) {
if (factory.componentType == component) { const factory = factories.componentFactories[i];
return factory; if (factory.componentType == component) {
return factory;
}
} }
} });
}); } catch (ex) {
return Promise.reject({message: 'Template has some errors and cannot be displayed.', debuginfo: ex});
}
} }
/** /**