Skip to content

Commit

Permalink
feat(ivy): add partial IVY support for *axLazyElement directive
Browse files Browse the repository at this point in the history
- unfortunately does NOT yet work with *axLazyElementDynamic directive
  • Loading branch information
tomastrajan committed Oct 23, 2019
1 parent 6d9a17e commit 911286b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,19 @@ export class LazyElementDynamicDirective implements OnInit {
this.elementsLoaderService
.loadElement(this.url, this.tag, this.isModule)
.then(() => {
const host = (this.template as any)._def.element.template.nodes[0]
.element;
host.name = this.tag;
if ((this.template as any)._declarationTContainer) {
// (this.template as any)._declarationTContainer.tagName = this.tag;
throw new Error(
'The *axLazyElementDynamic directive is currently does NOT support Angular Ivy, please use standard *axLazyElement directive instead!'
);
} else {
(this
.template as any)._def.element.template.nodes[0].element.name = this.tag;
}
this.vcr.clear();
this.vcr.createEmbeddedView(this.template);
})
.catch(() => {
.catch(error => {
const errorComponent =
elementConfig.errorComponent || options.errorComponent;
this.vcr.clear();
Expand All @@ -76,7 +82,8 @@ export class LazyElementDynamicDirective implements OnInit {
this.vcr.createComponent(factory);
} else {
console.error(
`${LOG_PREFIX} - Loading of element <${this.tag}> failed, please provide <ng-template #error>Loading failed...</ng-template> and reference it in *axLazyElementDynamic="errorTemplate: error" to display customized error message in place of element`
`${LOG_PREFIX} - Loading of element <${this.tag}> failed, please provide <ng-template #error>Loading failed...</ng-template> and reference it in *axLazyElementDynamic="errorTemplate: error" to display customized error message in place of element\n\n`,
error
);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ export class LazyElementDirective implements OnInit {
) {}

ngOnInit() {
const elementTag = (this.template as any)._def.element.template.nodes[0]
.element.name;
const tpl = this.template as any;
const elementTag = tpl._declarationTContainer
? tpl._declarationTContainer.tagName
: tpl._def.element.template.nodes[0].element.name;

const elementConfig =
this.elementsLoaderService.getElementConfig(elementTag) ||
Expand Down

0 comments on commit 911286b

Please sign in to comment.