import { Component } from '@angular/core'; @Component({ selector: 'app-root', template: ` <h2>Multiple Select</h2> <label [for]="combo" align="top">Select values:</label> <eui-combobox #combo style="width:300px" [(ngModel)]="value" [data]="data" [multiple]="true" [textFormatter]="formatText"></eui-combobox> <p *ngIf="value">Selected values: {{value | json}}</p> ` }) export class AppComponent { value: number[] = null; data = [ {value: 11, text: 'Mr. Nice'}, {value: 12, text: 'Narco'}, {value: 13, text: 'Bombasto'}, {value: 14, text: 'Celeritas'}, {value: 15, text: 'Magneta'}, {value: 16, text: 'RubberMan'}, {value: 17, text: 'Dynama'}, {value: 18, text: 'Dr IQ'}, {value: 19, text: 'Magma'}, {value: 20, text: 'Tornado'} ]; formatText(value: string){ if (this.value && this.value.length > 3){ return this.value.length + ' items selected'; } return value; } }
import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { BrowserModule } from '@angular/platform-browser'; import { HttpModule } from '@angular/http'; import { EasyUIModule } from 'easyui/easyui/easyui.module'; import { AppComponent } from './app.component'; @NgModule({ bootstrap: [ AppComponent ], declarations: [ AppComponent ], imports: [ FormsModule, BrowserModule, HttpModule, EasyUIModule ] }) export class AppModule { }
import { enableProdMode } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { AppModule } from './app.module'; enableProdMode(); platformBrowserDynamic().bootstrapModule(AppModule);