<!DOCTYPE html>
<html>

  <head>
    <title>angular2 playground</title>
    <link rel="stylesheet" type="text/css" href="https://unpkg.com/@swimlane/ngx-datatable@4.1.0/release/datatable.css" />
    <link rel="stylesheet" type="text/css" href="https://unpkg.com/@swimlane/ngx-datatable@4.1.0/release/material.css" />
    <link href="https://file.myfontastic.com/Jnf54BZCm7mSjGCxNRbfp3/icons.css" rel="stylesheet">
    <link rel="stylesheet" href="style.css" />
    
    <script src="https://unpkg.com/zone.js@0.6.23/dist/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="https://unpkg.com/typescript@2.0.7/lib/typescript.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>
// Code goes here

/* Styles go here */

body{
  font-family: 'RobotoDraft', 'Roboto', 'Helvetica Neue, Helvetica, Arial', sans-serif;
  text-align: center;
  font-style: normal;
  font-weight: 300;
  font-size: 1.4rem;
  line-height: 2rem;
  letter-spacing: 0.01rem;
  color: #212121;
  background-color: #f5f5f5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  margin:20px
}

.datatable {
	text-align: left;
	width:75%;
	margin:0 auto;
}
.datatable.vertical-scroll {
  height:70vh;
}
//our root app component
import { Component, NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { NgxDatatableModule } from '@swimlane/ngx-datatable';

@Component({
  selector: 'my-app',
  template: `
    <div>
      <h3>basic</h3>
      <ngx-datatable
        class='material'
        [rows]='rows'
        [columnMode]="'force'"
        [headerHeight]="50"
        [footerHeight]="0"
        [rowHeight]="50"
        [scrollbarV]="true"
        [scrollbarH]="true">
        <ngx-datatable-column name="ID" [width]="300"></ngx-datatable-column>
        <ngx-datatable-column name="Name"></ngx-datatable-column>
        <ngx-datatable-column name="Remark"></ngx-datatable-column>
      </ngx-datatable>
    </div>
  `
})
export class App {

  rows = [];

  constructor() {
    this.fetch((data) => {
      this.rows.push(...data);
    });
  }

  fetch(cb) {
    const req = new XMLHttpRequest();
    req.open('GET', 'http://realestateapi.techextensorproducts.com/api/LocationInfoes/GetCities');

    req.onload = () => {
      cb(JSON.parse(req.response));
    };

    req.send();
  }

}


@NgModule({
  imports: [ BrowserModule, NgxDatatableModule ],
  declarations: [ App ],
  bootstrap: [ App ]
})
export class AppModule {}
//main entry point
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './app';

platformBrowserDynamic().bootstrapModule(AppModule)
System.config({
  //use typescript for compilation
  transpiler: 'typescript',
  //typescript compiler options
  typescriptOptions: {
    emitDecoratorMetadata: true
  },
  //map tells the System loader where to look for things
  map: {
    app: "./src",
    '@angular': 'https://unpkg.com/@angular',
    'rxjs': 'https://unpkg.com/rxjs@5.0.0-rc.2',
    '@swimlane/ngx-datatable': 'https://unpkg.com/@swimlane/ngx-datatable@4.1.0'
  },
  //packages defines our app package
  packages: {
    app: {
      main: './bootstrap.ts',
      defaultExtension: 'ts'
    },
    '@angular/core': {
      main: 'bundles/core.umd.js',
      defaultExtension: 'js'
    },
    '@angular/compiler': {
      main: 'bundles/compiler.umd.js',
      defaultExtension: 'js'
    },
    '@angular/common': {
      main: 'bundles/common.umd.js',
      defaultExtension: 'js'
    },
    '@angular/platform-browser-dynamic': {
      main: 'bundles/platform-browser-dynamic.umd.js',
      defaultExtension: 'js'
    },
    '@angular/platform-browser': {
      main: 'bundles/platform-browser.umd.js',
      defaultExtension: 'js'
    },
    '@angular/forms': {
      main: 'index.js',
      defaultExtension: 'js'
    },
    '@angular/router': {
      main: 'index.js',
      defaultExtension: 'js'
    },
    rxjs: {
      defaultExtension: 'js'
    }
  }
});