<!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="style.css" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.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>
div.content {
  margin: 20px;
}
### Angular Starter Plunker - Typescript
var angularVersion;
if(window.AngularVersionForThisPlunker === 'latest'){
  angularVersion = ''; //picks up latest
}
else {
  angularVersion = '@' + window.AngularVersionForThisPlunker;
}

System.config({
  transpiler: 'ts',
  typescriptOptions: {
    emitDecoratorMetadata: true,
    experimentalDecorators: true
  },
  meta: {
  'typescript': {
		"exports": "ts"
	  }
	},
  paths: {
    'npm:': 'https://unpkg.com/'
  },
  map: {
    app: "./src",
    'ngx-duration-picker': 'https://unpkg.com/ngx-duration-picker@latest/bundles/ngx-duration-picker.umd.js',
    '@angular/core': 'npm:@angular/core'+angularVersion+'/bundles/core.umd.js',
    '@angular/common': 'npm:@angular/common'+angularVersion+'/bundles/common.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/upgrade': 'npm:@angular/upgrade'+angularVersion+'/bundles/upgrade.umd.js',
    '@angular/upgrade/static': 'npm:@angular/upgrade'+angularVersion+'/bundles/upgrade-static.umd.js',

    // other libraries
    'rxjs':                      'npm:rxjs',
    'ts':                        'npm:plugin-typescript',
    'typescript':                'npm:typescript'
  },
  //packages defines our app package
  packages: {
    app: {
      main: './main.ts',
      defaultExtension: 'ts'
    },
    rxjs: {
        main: 'index.js',
        defaultExtension: 'js'
    },
    "rxjs/operators": {
        main: 'index.js',
        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 { FormsModule, ReactiveFormsModule, FormControl, FormGroup } from '@angular/forms';

import { DurationPickerModule } from 'ngx-duration-picker';

@Component({
  selector: 'my-app',
  template: `
  
  <div class="container">
  <div class="row">
    <div class="col-xs-12">
      <div class="h1">Plain binding</div>

      <ngx-duration-picker [(value)]="myValue" [disabled]="disabled"></ngx-duration-picker>

    </div>
    <div class="col-xs-6">
      <div class="alert alert-info">
        {{ myValue }}
      </div>
      <button (click)="myValue = 'P7Y3M2W4DT1H3M5S'" class="btn btn-info">Set to value 'P7Y3M2W4DT1H3M5S'</button>
    </div>
    <div class="col-xs-6">
      <button (click)="disabled = !disabled" class="btn btn-warning">Toggle Enable/Disable</button>
    </div>
  </div>

  <hr>

  <div class="row">
    <div class="col-xs-12">
      <div class="h1">Reactive Form</div>
      <form [formGroup]="form">
        <ngx-duration-picker [formControlName]="'myDurationControl'"></ngx-duration-picker>
      </form>
    </div>

    <div class="row">
      <div class="col-xs-6">
        <div class="alert alert-info">
          {{ form.get('myDurationControl').value }}
        </div>
        <button (click)="setControlToValue('P7Y3M2W4DT1H3M5S')" class="btn btn-info">Set to value 'P7Y3M2W4DT1H3M5S'</button>
      </div>

      <div class="col-xs-6">
        <button (click)="toggleEnableDisableControl()" class="btn btn-warning">Toggle Enable/Disable</button>
      </div>

    </div>
    <br>
    <div class="row">
      <div class="col-xs-6">
        <div class="alert alert-success">
          {{ form.get('myDurationControl').touched ? 'Touched' : 'Untouched' }}
        </div>
        <button (click)="makeUntouched()" class="btn btn-success">Make untouched</button>
      </div>
    </div>
  </div>

  <hr>

  <div class="row">
      <div class="col-xs-12">
        <div class="h1">Negative Duration</div>
  
        <ngx-duration-picker [(value)]="myNegativeValue" [options]="{ showNegative: showNegative }"></ngx-duration-picker>
  
      </div>
      <div class="col-xs-6">
        <div class="alert alert-info">
          {{ myNegativeValue }}
        </div>
        <button (click)="myNegativeValue = '-P7Y3M2W4DT1H3M5S'" class="btn btn-info">Set to value '-P7Y3M2W4DT1H3M5S'</button>
      </div>

      <div class="col-xs-6">
          <button (click)="showNegative = !showNegative" class="btn btn-warning">
            <span *ngIf="!showNegative">Show </span>
            <span *ngIf="showNegative">Hide </span>
            Negative Durations</button>
        </div>
    </div>  
</div>
  `,
})
export class App {
  
  myValue;
  myNegativeValue;
  showNegative = true;
  disabled = false;
  form: FormGroup;

  ngOnInit() {
    this.form = new FormGroup({
      'myDurationControl': new FormControl(null),
    });
  }

  makeUntouched() {
    this.form.get('myDurationControl').markAsUntouched();
  }

  setControlToValue(newValue) {
    this.form.get('myDurationControl').setValue(newValue);
  }

  toggleEnableDisableControl() {
    if (this.form.get('myDurationControl').disabled) {
      this.form.get('myDurationControl').enable();
    } else {
      this.form.get('myDurationControl').disable();
    }
  }
}

@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    ReactiveFormsModule,
    DurationPickerModule,
  ],
  declarations: [ App ],
  bootstrap: [ App ]
})
export class AppModule {}