Articles in this section
Category / Section

How to get started easily with Syncfusion Angular 11 List Box?

2 mins read

A quick start project that helps you to create an Angular 11 List Box with a minimal code configurations.

The following section explains you how to create a simple angular 11 List Box component.

Prerequisites

 

Before start, we need following items to create Angular List Box in Angular 11 application.

 

Dependencies

 

The Angular 11 List Box is created from the Syncfusion ej2-angular-dropdowns package from npmjs, which are distributed in npm as @syncfusion scoped packages.

 

Creating Angular Project

 

  • Install Angular CLI 11 using below command.

    npm install -g @angular/cli@11.2.3

 

Note:

If you would like to follow and run the application in Angular 6 or Angular 5 or Angular 4, you need to replace the CLI command version number with the corresponding angular version number.

 

npm install -g @angular/cli@<CLI VERSION>

 

 

  • Create a new Angular 11 project using angular cli and navigate to the folder.

 

 

  1. ng new angular11-app
  2. cd angular11-app

 

Adding Angular List Box

 

  • After running the Angular 11 application successfully, configure the Angular List Box in this application. Install Angular List Box and EJ2 package using following command. 

 

  1. npm install @syncfusion/ej2-angular-dropdowns –save

 

  • The --save command will instruct the NPM to include a List Box package inside the dependencies section of the package.json.

 

  • Import list Box from installed package.

 

  • Import and inject the other required modules within the providers section of app.module.ts.

 

import { BrowserModule } from '@angular/platform-browser';

import { NgModule } from '@angular/core';

import { ListBoxComponent } from '@syncfusion/ej2-angular-dropdowns';

import { AppComponent } from './app.component';

import { FormsModule, ReactiveFormsModule } from '@angular/forms';

import { ButtonComponent } from '@syncfusion/ej2-angular-buttons';

 

@NgModule({

  declarations: [

    AppComponent,

    ListBoxComponent,

    ButtonComponent

 

  ],

  imports: [

    BrowserModule,

    FormsModule,

    ReactiveFormsModule

 

  ],

  providers: [],

  bootstrap: [AppComponent]

})

export class AppModule {}

 

  • Add the given below angular list box’s styles in styles.css.
    @import "../node_modules/@syncfusion/ej2-dropdowns/styles/material.css";
    
    

 

  • Add the angular List Box component in app.component.ts.

 

 import { Component } from '@angular/core';

@Component({

    selector: 'app-root',

    template: `<ejs-listbox [dataSource]='data'></ejs-listbox>`

})

 

export class AppComponent {

    public data: { [key: string]: Object }[] = [

        { text: 'Hennessey Venom', id: 'list-01' },

        { text: 'Bugatti Chiron', id: 'list-02' },

        { text: 'Bugatti Veyron Super Sport', id: 'list-03' },

        { text: 'SSC Ultimate Aero', id: 'list-04' },

        { text: 'Koenigsegg CCR', id: 'list-05' },

        { text: 'McLaren F1', id: 'list-06' },

        { text: 'Aston Martin One- 77', id: 'list-07' },

        { text: 'Jaguar XJ220', id: 'list-08' },

        { text: 'McLaren P1', id: 'list-09' },

        { text: 'Ferrari LaFerrari', id: 'list-10' }

    ];

}

 

  • Now serve the application using following command.

 

  1. ng serve

 

Once the files are compiled successfully, it will serve the site at localhost:4200

Screenshot:

ListBox

 

Summary

 

Refer to our documentation and online samples for more features. If you have any queries, please let us know in comments below.  You can also contact us through our Support forum or Direct-Trac. We are happy to assist you!

Please refer the Github samples: Angular 11 List Box Component

Conclusion

I hope you enjoyed learning about how to get started with Angular 11 ListBox.

You can refer to our Angular List Box feature tour
page to know about its other groundbreaking feature representations documentation and how to quickly get started for configuration specifications.  You can also explore our Angular List Box example
to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied