I am trying to create a table. Each odd row has data and each even row is an expandable row. I need to dynamically load data to the expandable row when user press the expand icon.
I can't find the way to do it with ComponentResolver, local variable is useless inside a loop. is there another angular way except using the ElementRef workaround?
<template ngFor let-row="$implicit" [ngForOf]="rows" let-i="index">
        <tr class="row-rule-review ">
            <td class="col-applications">
            <img class="stack-img" src="images/expand.png" (click)="toggleButton(i)">
        </td>
             ...
        </tr>
        <tr class="row-extended">
            <td colspan="8">
                <div #target class="extended-content" id="extended-content-{{i}}" [style.height.px]="isExpand[i] ? 150 : 0">
                </div>
            </td>
        </tr>        
    </template>
the function on the component with :
toggleButton(index, cmp) {
        let that = this;
        if (this.isExpand[index]) {
            this.isExpand[index] = false;
        }
        else {
            if (this.extendComponent[index] === undefined) {
                this.resolver.resolveComponent(RowExpand).then((factory: ComponentFactory<any>) => {
                    that.extendComponent[index] = cmp.createComponent(factory);
                });
            }
            that.isExpand[index] = true;
        }
    }
in this senario, cmp.createComponent is undefined
 
     
     
     
    