<!DOCTYPE html>
<html>

  <head>
    <base href="." />
    <script type="text/javascript" charset="utf-8">
      window.AngularVersionForThisPlunker = 'latest'
    </script>
    <title>angular playground</title>
    
    <link rel="stylesheet" href="https://unpkg.com/primeng/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/resources/primeng.min.css" />
    
    <link rel="stylesheet" href="style.css" />
    <script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script>
    <script src="https://unpkg.com/zone.js/dist/zone.js"></script>
    <script src="https://unpkg.com/zone.js/dist/long-stack-trace-zone.js"></script>
    <script src="https://unpkg.com/reflect-metadata@0.1.3/Reflect.js"></script>
    <script src="https://unpkg.com/systemjs@0.19.31/dist/system.js"></script>
    <script src="config.js"></script>
    <script>
    System.import('app')
      .catch(console.error.bind(console));
  </script>
  </head>

  <body>
    <my-app>
    loading...
  </my-app>
  </body>

</html>
/* Styles go here */

### Angular Starter Plunker - Typescript
var angularVersion;
if(window.AngularVersionForThisPlunker === 'latest'){
  angularVersion = ''; //picks up latest
}
else {
  angularVersion = '@' + window.AngularVersionForThisPlunker;
}

System.config({
  //use typescript for compilation
  transpiler: 'typescript',
  //typescript compiler options
  typescriptOptions: {
    emitDecoratorMetadata: true
  },
  paths: {
    'npm:': 'https://unpkg.com/'
  },
  //map tells the System loader where to look for things
  map: {
    
    'app': './src',
    '@angular/core': 'npm:@angular/core'+ angularVersion + '/bundles/core.umd.js',
    '@angular/common': 'npm:@angular/common' + angularVersion + '/bundles/common.umd.js',
    '@angular/common/http': 'npm:@angular/common' + angularVersion + '/bundles/common-http.umd.js',
    '@angular/compiler': 'npm:@angular/compiler' + angularVersion  + '/bundles/compiler.umd.js',
    '@angular/platform-browser': 'npm:@angular/platform-browser' + angularVersion + '/bundles/platform-browser.umd.js',
    '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic' + angularVersion + '/bundles/platform-browser-dynamic.umd.js',
    '@angular/http': 'npm:@angular/http' + angularVersion + '/bundles/http.umd.js',
    '@angular/router': 'npm:@angular/router' + angularVersion +'/bundles/router.umd.js',
    '@angular/forms': 'npm:@angular/forms' + angularVersion + '/bundles/forms.umd.js',
    '@angular/animations': 'npm:@angular/animations' + angularVersion + '/bundles/animations.umd.js',
    '@angular/platform-browser/animations': 'npm:@angular/platform-browser' + angularVersion + '/bundles/platform-browser-animations.umd.js',
    '@angular/animations/browser': 'npm:@angular/animations' + angularVersion + '/bundles/animations-browser.umd.js',
    
    '@angular/core/testing': 'npm:@angular/core' + angularVersion + '/bundles/core-testing.umd.js',
    '@angular/common/testing': 'npm:@angular/common' + angularVersion + '/bundles/common-testing.umd.js',
    '@angular/common/http/testing': 'npm:@angular/common' + angularVersion + '/bundles/common-http-testing.umd.js',
    '@angular/compiler/testing': 'npm:@angular/compiler' + angularVersion + '/bundles/compiler-testing.umd.js',
    '@angular/platform-browser/testing': 'npm:@angular/platform-browser' + angularVersion + '/bundles/platform-browser-testing.umd.js',
    '@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic' + angularVersion + '/bundles/platform-browser-dynamic-testing.umd.js',
    '@angular/http/testing': 'npm:@angular/http' + angularVersion + '/bundles/http-testing.umd.js',
    '@angular/router/testing': 'npm:@angular/router' + angularVersion + '/bundles/router-testing.umd.js',
    'tslib': 'npm:tslib@1.6.1',
    'rxjs': 'npm:rxjs',
    'typescript': 'npm:typescript@2.2.1/lib/typescript.js',
    // other libraries
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
      'primeng':                   'npm:primeng' 
  },
  //packages defines our app package
  packages: {
    app: {
      main: './main.ts',
      defaultExtension: 'ts'
    },
    rxjs: {
      defaultExtension: 'js'
    }
  }
});
//main entry point
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './app';

platformBrowserDynamic().bootstrapModule(AppModule)
//our root app component
import {Component, NgModule, VERSION} from '@angular/core'
import {BrowserModule} from '@angular/platform-browser'
import { TreeTableModule } from 'primeng/primeng';
import { TreeTable, TreeNode } from 'primeng/primeng';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

@Component({
  selector: 'my-app',
  template: `
    <p-treeTable [value]="data">

      <p-column field="label" header=""></p-column>
      
      <p-column header="DATA">
          <ng-template let-col let-clustersArray="rowData.data.clusters" pTemplate="body">
  
              <div *ngFor="let cluster of clustersArray">
                  {{cluster}}
              </div>
              
          </ng-template>
      </p-column>
  
  </p-treeTable>
  `,
})
export class App implements OnInit {
  name:string;
  constructor() { }
  
  data: TreeNode[];
  result: [];
  
  ngOnInit() {
  
    this.result = [
                		{ col1: "A" , col2: "a" , col3: "1", col4: [10,15] },
                		{ col1: "A" , col2: "c" , col3: "1", col4: [30,35] },
                		{ col1: "B" , col2: "b" , col3: "1", col4: [20,25] },
                		{ col1: "C" , col2: "d" , col3: "1", col4: [40,45] },
                		{ col1: "C" , col2: "d" , col3: "2", col4: [50,55] },
                		{ col1: "D" , col2: "e" , col3: "3", col4: [60,65] },
                		{ col1: "D" , col2: "e" , col3: "4", col4: [70,75] },
                		{ col1: "D" , col2: "f" , col3: "1", col4: [80,85] }
                	];
    this.initializeSolutionArray(); // if you want to see the solution
  }
  
  initializeSolutionArray() {
    this.data = [
  		{
  			// COL1
  			data:{
  				label:"A"
  			},
  			children:[
  				{
  					// COL2
  					data:{
  						label: "a"
  					},
  					children:[
  						{
  							// COL3
  							data:{
  								label: "1",
  								clusters: [10,15]
  							}
  						}
  					]
  				},
  				{
  					// COL2
  					data:{
  						label: "c"
  					},
  					children:[
  						{
  							// COL3
  							data:{
  								label: "1",
  								clusters: [30,35]
  							}
  						}
  					]
  				}
  			]
  		},
  		{
  			// COL1
  			data:{
  				label:"B"
  			},
  			children:[
  				{
  					// COL2
  					data:{
  						label: "b"
  					},
  					children:[
  						{
  							// COL3
  							data:{
  								label: "1",
  								clusters: [20,25]
  							}
  						}
  					]
  				}
  			]
  		},
  		{
  			// COL1
  			data:{
  				label:"C"
  			},
  			children:[
  				{
  					// COL2
  					data:{
  						label: "d"
  					},
  					children:[
  						{
  							// COL3
  							data:{
  								label: "1",
  								clusters: [40,45]
  							}
  						},
  						{
  							// COL3
  							data:{
  								label: "2",
  								clusters: [50,55]
  							}
  						}
  					]
  				}
  			]
  		},
  		{
  			// COL1
  			data:{
  				label:"D"
  			},
  			children:[
  				{
  					// COL2
  					data:{
  						label: "e"
  					},
  					children:[
  						{
  							// COL3
  							data:{
  								label: "3",
  								clusters: [60,65]
  							}
  						},
  						{
  							// COL3
  							data:{
  								label: "4",
  								clusters: [70,75]
  							}
  						}
  					]
  				},
  				{
  					// COL2
  					data:{
  						label: "f"
  					},
  					children:[
  						{
  							// COL3
  							data:{
  								label: "3",
  								clusters: [80,85]
  							}
  						}
  					]
  				}
  			]
  		}
  	];  
  }
  
}

@NgModule({
  imports: [ BrowserModule, BrowserAnimationsModule, TreeTableModule ],
  declarations: [ App ],
  bootstrap: [ App ]
})
export class AppModule {}