Having trouble getting help?
Contact Support
Contact Support
Form submit in Angular List box component
27 Apr 20242 minutes to read
In the following code snippet, the value that is in selected state will be sent on form submit.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { ListBoxComponent,ListBoxAllModule } from '@syncfusion/ej2-angular-dropdowns'
import { ButtonComponent } from '@syncfusion/ej2-angular-buttons'
import { Component } from '@angular/core';
@Component({
imports: [
FormsModule, ReactiveFormsModule,ListBoxAllModule
],
standalone: true,
selector: 'app-container',
template: `<div class="e-section-control">
<form><ejs-listbox id="listbox" [dataSource]="data" height="290px"></ejs-listbox>
<button class="e-btn">Submit</button></form></div>`
})
export class AppComponent {
public data: { [key: string]: Object }[] = [
{ text: 'Hennessey Venom' },
{ text: 'Bugatti Chiron' },
{ text: 'Bugatti Veyron Super Sport' },
{ text: 'SSC Ultimate Aero' },
{ text: 'Koenigsegg CCR' },
{ text: 'McLaren F1' },
{ text: 'Aston Martin One- 77' },
{ text: 'Jaguar XJ220' },
{ text: 'McLaren P1' },
{ text: 'Ferrari LaFerrari' },
];
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));