Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions projects/igniteui-angular-elements/src/app/custom-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
const componentRef = (this as any).componentRef as ComponentRef<any>;
const viewRef = componentRef.injector.get(ViewContainerRef);
this._templateWrapper = viewRef.createComponent(TemplateWrapperComponent).instance;
this._templateWrapper.owner = componentRef.instance;
}
return this._templateWrapper;
}
Expand Down Expand Up @@ -79,6 +80,13 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
.map(parentType => this.config.find(x => x.component === parentType))
.filter(x => x.selector);

const template = (element as any).getRootNode().querySelector('[tmpl_owner]');
if (template) {
const parentOfTmlp = element.closest<IgcNgElement>('#' + template.getAttribute("tmpl_owner"));
if ((parentOfTmlp?.ngElementStrategy as any)?.componentRef) {
this.angularParent = (parentOfTmlp.ngElementStrategy as any).componentRef;
}
}
if (configParents?.length) {
let node = element as IgcNgElement;
while (node?.parentElement) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@for (templateFunc of templateFunctions; track templateFunc) {
<ng-template let-context="context">
<div #container style="display: contents;"></div>
<div #container style="display: contents;" [attr.tmpl_owner]="owner?.id"></div>
{{ litRender(container, templateFunc, context) }}
</ng-template>
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ type TemplateFunction = (arg: any) => TemplateResult;
})
export class TemplateWrapperComponent {

public owner: any;

public templateFunctions: TemplateFunction[] = [];

/**
Expand Down
6 changes: 5 additions & 1 deletion projects/igniteui-angular-elements/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,11 @@ <h3 class="ig-typography__h6">Flat Grid (MRL column layout)</h3>
<igc-combo ${ref(focusCallback)} style="width:100%; height:100%" .data=${northwindProducts} value-key="ProductName" @igcChange=${(e) => ctx.cell.editValue = e.detail.newValue} single-select>
</igc-combo>
`;
grid1.detailTemplate = (ctx) => html`<div><span class="categoryStyle">Stock: ${ctx.implicit.InStock}</span></div>`;
grid1.detailTemplate = (ctx) => {
return html`<div>
<igc-grid auto-generate="true"></igc-grid>
</div>`;
}

grid2.querySelector('igc-column[field="ProductName"]').inlineEditorTemplate = (ctx) =>
html`
Expand Down
Loading