//our root app component
import {Component, OnInit, NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import { TreeTableModule } from 'primeng/primeng';
import { TreeTable, TreeNode } from 'primeng/primeng';

// Array.unique()
declare global {
	interface Array<T> {
		unique(): Array<T>;
	}
}
Array.prototype.unique = function () {
	let n: any[] = [], r: any[] = [];
	for (var i = 0; i < this.length; i++) {
		if (!n[this[i]]) {
			n[this[i]] = true;
			r.push(this[i]);
		}
	}
	return r;
}
// data
class Supplier {
	Id: number;
	CompanyName?: string;
	City?: string;
	Region?: string;
	Country?: string;
}
const suppliers: Supplier[] = [
	{ Id: 24, CompanyName: 'G\'day, Mate', City: 'Sydney', Region: 'NSW', Country: 'Australia' },
	{ Id: 7, CompanyName: 'Pavlova, Ltd.', City: 'Melbourne', Region: 'Victoria', Country: 'Australia' },
	{ Id: 10, CompanyName: 'Refrescos Americanas LTDA', City: 'Sao Paulo', Region: null, Country: 'Brazil' },
	{ Id: 29, CompanyName: 'Forets d\'erables', City: 'Ste-Hyacinthe', Region: 'Quebec', Country: 'Canada' },
	{ Id: 25, CompanyName: 'Ma Maison', City: 'Montreal', Region: 'Quebec', Country: 'Canada' },
	{ Id: 2, CompanyName: 'New Orleans Cajun Delights', City: 'New Orleans', Region: 'LA', Country: 'USA' },
	{ Id: 19, CompanyName: 'New England Seafood Cannery', City: 'Boston', Region: 'MA', Country: 'USA' },
	{ Id: 3, CompanyName: 'Grandma Kelly\'s Homestead', City: 'Ann Arbor', Region: 'MI', Country: 'USA' },
	{ Id: 16, CompanyName: 'Bigfoot Breweries', City: 'Bend', Region: 'OR', Country: 'USA' }
];
// component
@Component({
  selector: 'my-app',
  templateUrl: 'app/app.template.html'
})
export class AppComponent {
	nodes: TreeNode[] = [];

	constructor() {}

	ngOnInit() {
		this.getSupplierCountries().then((countries: string[]) => {
			this.nodes = countries.map(country => <TreeNode> {
				label: 'Country: ' + country,
				leaf: false,
				level: 0,
				value: country
			});
		});
	}

	nodeExpand(event: any) {
		if (event.node) {
			if (event.node.level == 0) {
				let country = event.node.value;
				this.getSupplierCountryRegions(country).then((regions: string[]) => {
					event.node.children = regions.map(region => <TreeNode>{
						label: 'Region: ' + (region ? region : '[none]'),
						leaf: false,
						level: 1,
						value: [country, region]
					});
				});
			}
			else if (event.node.level == 1) {
				let country = event.node.value[0];
				let region = event.node.value[1];
				this.getSuppliersByCountryRegion(country, region).then((suppliers: Supplier[]) => {
					event.node.children = suppliers.map(s => <TreeNode>{
						data: s,
						leaf: true,
						level: 2,
					});
				});
			}
			else
				window.alert('Invalid node type');
		}
	}

	// data service
	getSupplierCountries(): Promise<string[]> {
		return new Promise((resolve, reject) => {
			resolve(suppliers.map(s => s.Country).unique());
		});
	}
	getSupplierCountryRegions(country: string): Promise<string[]> {
		return new Promise((resolve, reject) => {
			resolve(suppliers.filter(s => s.Country == country).map(s => s.Region).unique());
		});
	}
	getSuppliersByCountryRegion(country: string, region: string): Promise<Supplier[]> {
		return new Promise((resolve, reject) => {
			resolve(suppliers.filter(s => s.Country == country && s.Region == region));
		});
	}
}
import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { TreeTableModule } from 'primeng';

import { AppComponent }   from './app.component';

// Import PrimeNG modules
import { 
  ButtonModule,
  OverlayPanelModule
} from 'primeng';

@NgModule({
  imports:      [ 
    BrowserModule, 
		TreeTableModule
  ],
  declarations: [ AppComponent ],
  bootstrap:    [ AppComponent ]
})

export class AppModule { }


/*
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
*/
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app.module';

const platform = platformBrowserDynamic();
platform.bootstrapModule(AppModule);
body {
  padding: 2em;
  font-family: Arial, Helvetica, sans-serif;
}

<!DOCTYPE html>
<html>

  <head>
    <title>Angular QuickStart</title>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <!-- Bootstrap -->
    <link data-require="bootstrap@4.0.5" data-semver="4.0.5" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" />
    <!-- <script data-require="bootstrap@4.0.5" data-semver="4.0.5" src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js"></script>-->
    <link rel="stylesheet" href="styles.css" />
    <!-- PrimeNG style dependencies -->
    <link rel="stylesheet" href="https://unpkg.com/primeng@2.0.0/resources/themes/omega/theme.css" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
    <link rel="stylesheet" href="https://unpkg.com/primeng@2.0.0/resources/primeng.min.css" />
    <!-- 1. Load libraries -->
    <!-- Polyfill for older browsers -->
    <script src="https://unpkg.com/core-js/client/shim.min.js"></script>
    <script src="https://unpkg.com/zone.js@0.6.25?main=browser"></script>
    <script src="https://unpkg.com/reflect-metadata@0.1.8"></script>
    <script src="https://unpkg.com/systemjs@0.19.39/dist/system.src.js"></script>
    <!-- 2. Configure SystemJS -->
    <script src="systemjs.config.js"></script>
  </head>

  <!-- 3. Display the application -->
  <body>
    <my-app>Loading...</my-app>
  </body>

  <!-- 
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
-->
</html>
/**
 * WEB ANGULAR VERSION
 * (based on systemjs.config.js in angular.io)
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
  System.config({
    // DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
    transpiler: 'ts',
    typescriptOptions: {
      // Copy of compiler options in standard tsconfig.json
      "target": "es5",
      "module": "commonjs",
      "moduleResolution": "node",
      "sourceMap": true,
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "noImplicitAny": true,
      "suppressImplicitAnyIndexErrors": true
    },
    meta: {
      'typescript': {
        "exports": "ts"
      }
    },
    paths: {
      // paths serve as alias
      'npm:': 'https://unpkg.com/'
    },
    // map tells the System loader where to look for things
    map: {
      // our app is within the app folder
      app: 'app',

      // angular bundles
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
      '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
      '@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',

      // other libraries
      'rxjs':                      'npm:rxjs',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
      'ts':                        'npm:plugin-typescript@4.0.10/lib/plugin.js',
      'typescript':                'npm:typescript@2.0.3/lib/typescript.js',
      'primeng':                   'npm:primeng@2.0.0-rc.3/primeng.js'

    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        main: './main.ts',
        defaultExtension: 'ts'
      },
      rxjs: {
        defaultExtension: 'js'
      },
      primeng: {
        defaultExtension: 'js'
      }
    }
  });

  if (!global.noBootstrap) { bootstrap(); }

  // Bootstrap the `AppModule`(skip the `app/main.ts` that normally does this)
  function bootstrap() {
    console.log('Auto-bootstrapping');

    // Stub out `app/main.ts` so System.import('app') doesn't fail if called in the index.html
    System.set(System.normalizeSync('app/main.ts'), System.newModule({ }));

    // bootstrap and launch the app (equivalent to standard main.ts)
    Promise.all([
      System.import('@angular/platform-browser-dynamic'),
      getAppModule()
    ])
    .then(function (imports) {
      var platform = imports[0];
      var app      = imports[1];
      platform.platformBrowserDynamic().bootstrapModule(app.AppModule);
    })
    .catch(function(err){ console.error(err); });
  }

  // Import AppModule or make the default AppModule if there isn't one
  // returns a promise for the AppModule
  function getAppModule() {
    if (global.noAppModule) {
      return makeAppModule();
    }
    return System.import('app/app.module').catch(makeAppModule)
  }

  function makeAppModule() {
    console.log('No AppModule; making a bare-bones, default AppModule');

    return Promise.all([
      System.import('@angular/core'),
      System.import('@angular/platform-browser'),
      System.import('app/app.component')
    ])
    .then(function (imports) {

      var core    = imports[0];
      var browser = imports[1];
      var appComp = imports[2].AppComponent;

      var AppModule = function() {}

      AppModule.annotations = [
        new core.NgModule({
          imports:      [ browser.BrowserModule ],
          declarations: [ appComp ],
          bootstrap:    [ appComp ]
        })
      ]
      return {AppModule: AppModule};
    })
  }
})(this);
<h2>Suppliers</h2>
<p-treeTable [value]="nodes" (onNodeExpand)="nodeExpand($event)">
    <p-header>List of Suppliers 2</p-header>
    <p-column field="CompanyName" header="Company Name"></p-column>
    <p-column field="City" header="City"></p-column>
    <p-column field="Region" header="Region"></p-column>
    <p-column field="Country" header="Country"></p-column>
</p-treeTable>
# PrimeNG Issue Template
Please create a test case and attach the link of the plunkr to your github issue report.
<div class="ui-treetable-row" [ngClass]="{'ui-state-highlight':isSelected(),'ui-treetable-row-selectable':treeTable.selectionMode}">
	<ng-container *ngIf="node.data">
		<td *ngFor="let col of treeTable.columns; let i=index" [ngStyle]="col.style" [class]="col.styleClass" (click)="onRowClick($event)">
			<a href="#" *ngIf="i==0" class="ui-treetable-toggler fa fa-fw ui-c" [ngClass]="{'fa-caret-down':node.expanded,'fa-caret-right':!node.expanded}"
                    [ngStyle]="{'margin-left':level*16 + 'px','visibility': isLeaf() ? 'hidden' : 'visible'}"
                    (click)="toggle($event)"
				[title]="node.expanded ? labelCollapse : labelExpand"></a>
			<span *ngIf="!col.template">{{resolveFieldData(node.data,col.field)}}</span>
			<p-columnBodyTemplateLoader [column]="col" [rowData]="node" *ngIf="col.template"></p-columnBodyTemplateLoader>
		</td>
	</ng-container>
	<td *ngIf="!node.data" [attr.colspan]="treeTable.columns.length" (click)="onRowClick($event)">
		<a href="#" class="ui-treetable-toggler fa fa-fw ui-c" [ngClass]="{'fa-caret-down':node.expanded,'fa-caret-right':!node.expanded}"
			[ngStyle]="{'margin-left':level*16 + 'px','visibility': isLeaf() ? 'hidden' : 'visible'}" (click)="toggle($event)" 
			[title]="node.expanded ? labelCollapse : labelExpand"></a>
		<span>{{ node.label }}</span>
	</td>
</div>
<div *ngIf="node.children && node.expanded" class="ui-treetable-row" style="display:table-row">
	<td [attr.colspan]="treeTable.columns.length" class="ui-treetable-child-table-container">
		<table>
			<tbody pTreeRow *ngFor="let childNode of node.children" [node]="childNode" [level]="level+1" [labelExpand]="labelExpand" [labelCollapse]="labelCollapse"></tbody>
		</table>
	</td>
</div>