<!DOCTYPE html>
<html>

  <head>
    <base href="." />
    <title>angular playground</title>
    <link href="https://unpkg.com/@ng-select/ng-select/themes/default.theme.css" rel="stylesheet">
    <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>
  <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.css">
    <script src="https://use.fontawesome.com/7d64cb55fa.js"></script>
    <link rel="stylesheet" href="style.css">
  </head>

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

</html>
import {Component, OnInit, NgModule, ViewChild} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {FormControl, FormGroup, ReactiveFormsModule, FormsModule} from '@angular/forms';
import {NgSelectModule, NgOption} from '@ng-select/ng-select';

@Component({
    selector: 'my-app',
    template: `
        <h2>Resetable</h2>
        <button (click)="reset()">RESET</button>
        <ng-select [items]="cities"
                   bindLabel="name"
                   placeholder="Select city"
                   [clearable]="false"
                   [(ngModel)]="resettableCity">
        </ng-select>
        <p>
            Resetttable city: {{resettableCity | json}}
        </p>
        <hr />
        <hr />
        <h2>Pick & clear</h2>
        <ng-select [items]="cities"
                   bindLabel="name"
                   placeholder="Select city"
                   (ngModelChange)="change($event)"
                   [clearable]="false"
                   [ngModel]="selectedCity">
        </ng-select>
        <p>
            Selected city: {{selectedCity | json}}
        </p>
        <p>
            Picked city: {{pickedCity | json}}
        </p>
`
})
export class App implements OnInit {

    cities = [
        {id: 1, name: 'Vilnius'},
        {id: 2, name: 'Kaunas'},
        {id: 3, name: 'Pavilnys'},
        {id: 4, name: 'PabradÄ—'},
        {id: 5, name: 'KlaipÄ—da'}
    ];
    
    resettableCity: any;
    selectedCity: any;
    pickedCity: any;

    constructor() {
    }
    
    private reset(): void {
      this.resettableCity = null;
    }
    
    private change($event): void {
      this.pickedCity = $event;
      this.selectedCity = null;
    }
}

@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    NgSelectModule
  ],
  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
  },
  paths: {
    'npm:': 'https://unpkg.com/'
  },
  //map tells the System loader where to look for things
  map: {
    
    'app': './src',
    
    '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
    '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
    '@angular/common/http': 'npm:@angular/common/bundles/common-http.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/forms': 'npm:@angular/forms/bundles/forms.umd.js',
    
    
    '@ng-select/ng-select': 'npm:@ng-select/ng-select@0.23.1/bundles/ng-select.umd.js',
    'rxjs': 'npm:rxjs',
    'typescript': 'npm:typescript@2.2.1/lib/typescript.js',
    'tslib': 'npm:tslib'
  },
  //packages defines our app package
  packages: {
    app: {
      main: './main.ts',
      defaultExtension: 'ts'
    },
    rxjs: {
      defaultExtension: 'js'
    },
    '@ng-select/ng-select': {
      defaultExtension: 'js'
    }
  }
});
body {
  padding: 10px;
}

p {
  margin-top:20px;
}

label {
  margin-top: 20px;
  font-size: 18px;
  font-weight: 600;
}