<!DOCTYPE html>
<html>
<head>
<base href="." />
<title>ng-select playground</title>
<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>
<cities-page>
loading...
</cities-page>
</body>
</html>
import {Component, NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {FormsModule} from '@angular/forms';
import {NgSelectModule} from '@ng-select/ng-select';
@Component({
selector: 'cities-page',
template: `
<label>
<a href="https://github.com/ng-select/ng-select">@ng-select/ng-select</a> github issue basic template
</label>
<ng-select [items]="cities"
bindLabel="name"
bindValue="id"
placeholder="Select city"
[(ngModel)]="selectedCityId">
</ng-select>
<p>
Selected city ID: {{selectedCityId}}
</p>
`
})
export class CitiesPageComponent {
cities = [
{id: 1, name: 'Vilnius'},
{id: 2, name: 'Kaunas'},
{id: 3, name: 'PabradÄ—'},
{id: 3, name: 'KlaipÄ—da'},
{id: 3, name: 'Nida'}
];
selectedCityId: any;
}
@NgModule({
imports: [
BrowserModule,
FormsModule,
NgSelectModule
],
declarations: [ CitiesPageComponent ],
bootstrap: [ CitiesPageComponent ]
})
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/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.16.0/bundles/ng-select.umd.js',
'rxjs': 'npm:rxjs',
'typescript': 'npm:typescript@2.2.1/lib/typescript.js'
},
//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;
}