These are chat archives for AngularClass/angular2-webpack-starter

22nd
Dec 2017
Thuyet Le Van
@tuoitrexuquang
Dec 22 2017 02:52

Hi All, i'm trying build a tree menu and render it to view. bellow my code

this.menu = this.renderTreeMenu(data)

private renderTreeMenu(data: []) {
    let html = "";
    html += '<ul>';
    for (let i = 0; i < data.length; i++) {
        let element = data[i];
        html += '<li><a (click)="handleClick()">' + data[i].name + '</a>';
        if (data[i].children && data[i].children.length > 0) {
            html += this.renderTreeMenu(data[i].children)
        }
        html += '</li>';
    }
    html += '</ul>';

    return html;
}

View
.tree-view([innerHTML]="menu")

pls for me ask, how can i handle binding event click for this case?