The MultiSelect allows user to add a new non-present option to the component value when
allowCustomValue
is enabled. while selecting the new custom value
customValueSelection
event will be triggered.
The following sample demonstrates configuration of custom value support with the MultiSelect component.
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
// specifies the template string for the MultiSelect component
template: `<ejs-multiselect id='multiselectelement' [dataSource]='sportsData' [fields]='fields' [allowCustomValue]='true' [placeholder]='placeholder'></ejs-multiselect>`
})
export class AppComponent {
constructor() {
}
// defined the array of data
public sportsData: { [key: string]: Object }[] = [
{ id: 'game1', sports: 'Badminton' },
{ id: 'game2', sports: 'Football' },
{ id: 'game3', sports: 'Tennis' }
];
// map the appropriate column
public fields: Object = { text: 'sports', value: 'id' };
// set the placeholder to the MultiSelect input
public placeholder: string = 'Select games';
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { MultiSelectModule } from '@syncfusion/ej2-angular-dropdowns';
import { ButtonModule } from '@syncfusion/ej2-angular-buttons';
/**
* Module
*/
@NgModule({
imports: [
BrowserModule,FormsModule, ReactiveFormsModule, MultiSelectModule, ButtonModule
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);