Skip to content

Commit 2bc0f82

Browse files
Merge pull request #1 from SyncfusionExamples/888861-AngListBoxGS
Updated Angular Listbox getting started sample
2 parents 0af642a + 9c2b48f commit 2bc0f82

10 files changed

+127
-2
lines changed

README.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
1-
# getting-started-with-the-angular-listbox-component
2-
A quick-start Angular project that shows how to add the Angular Listbox Component to a Angular app. This project contains code to add few of the control’s basic features, like binding data and selecting items.
1+
# Getting started with the Angular Listbox Component
2+
3+
A quick-start Angular project that shows how to add the Angular Listbox Component to a Angular app. This project contains code to add few of the control’s basic features, like binding data and selecting items.
4+
5+
Refer to the following documentation to learn about the Angular Dashboard Layout component:
6+
https://ej2.syncfusion.com/angular/documentation/list-box/getting-started
7+
8+
Check out this online example of the Angular Dashboard Layout component:
9+
https://ej2.syncfusion.com/angular/demos/#/bootstrap5/list-box/default
10+
11+
## Project prerequisites
12+
Make sure that you have the compatible versions of [Visual Studio Code](https://code.visualstudio.com/download ) and [NodeJS](https://nodejs.org/en/download) or later version in your machine before starting to work on this project.
13+
14+
## How to run this application
15+
To run this application, you need to first clone the `getting-started-with-the-angular-listbox-component` repository and then open it in Visual Studio Code. Now, simply build and run your project using `npm start` command to view the output

src/app/app.component.css

Whitespace-only changes.

src/app/app.component.html

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="container">
2+
<ejs-listbox [dataSource]='data' [fields]="setfield" [selectionSettings]="selection"></ejs-listbox>
3+
</div>

src/app/app.component.spec.ts

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { TestBed } from '@angular/core/testing';
2+
import { AppComponent } from './app.component';
3+
4+
describe('AppComponent', () => {
5+
beforeEach(async () => {
6+
await TestBed.configureTestingModule({
7+
imports: [AppComponent],
8+
}).compileComponents();
9+
});
10+
11+
it('should create the app', () => {
12+
const fixture = TestBed.createComponent(AppComponent);
13+
const app = fixture.componentInstance;
14+
expect(app).toBeTruthy();
15+
});
16+
17+
it(`should have the 'angular-listbox-getting-started' title`, () => {
18+
const fixture = TestBed.createComponent(AppComponent);
19+
const app = fixture.componentInstance;
20+
expect(app.title).toEqual('angular-listbox-getting-started');
21+
});
22+
23+
it('should render title', () => {
24+
const fixture = TestBed.createComponent(AppComponent);
25+
fixture.detectChanges();
26+
const compiled = fixture.nativeElement as HTMLElement;
27+
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, angular-listbox-getting-started');
28+
});
29+
});

src/app/app.component.ts

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { Component } from '@angular/core';
2+
import { RouterOutlet } from '@angular/router';
3+
import { ListBoxComponent, ListBoxModule, CheckBoxSelection } from '@syncfusion/ej2-angular-dropdowns';
4+
import { ButtonComponent } from '@syncfusion/ej2-angular-buttons'
5+
6+
ListBoxComponent.Inject(CheckBoxSelection);
7+
8+
@Component({
9+
selector: 'app-root',
10+
standalone: true,
11+
imports: [RouterOutlet, ListBoxModule ],
12+
templateUrl: './app.component.html',
13+
styleUrl: './app.component.css'
14+
})
15+
export class AppComponent {
16+
public data: { [key: string]: Object }[] = [
17+
{ id: 'game1', sports: 'Badminton' },
18+
{ id: 'game2', sports: 'Cricket'},
19+
{ id: 'game3', sports: 'Football'},
20+
{ id: 'game4', sports: 'Golf'},
21+
{ id: 'game5', sports: 'Tennis'},
22+
{ id: 'game6', sports: 'Basket Ball'},
23+
{ id: 'game7', sports: 'Base Ball'},
24+
{ id: 'game8', sports: 'Hockey'},
25+
{ id: 'game9', sports: 'Volley Ball'}
26+
];
27+
28+
public fieldSettings = {
29+
text: "sports",
30+
value: "id"
31+
}
32+
33+
public selection = { mode: "Single", showCheckbox: false }
34+
}

src/app/app.config.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
2+
import { provideRouter } from '@angular/router';
3+
4+
import { routes } from './app.routes';
5+
6+
export const appConfig: ApplicationConfig = {
7+
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes)]
8+
};

src/app/app.routes.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { Routes } from '@angular/router';
2+
3+
export const routes: Routes = [];

src/index.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>AngularListboxGettingStarted</title>
6+
<base href="/">
7+
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<link rel="icon" type="image/x-icon" href="favicon.ico">
9+
</head>
10+
<body>
11+
<app-root></app-root>
12+
</body>
13+
</html>

src/main.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { bootstrapApplication } from '@angular/platform-browser';
2+
import { appConfig } from './app/app.config';
3+
import { AppComponent } from './app/app.component';
4+
5+
6+
7+
import { registerLicense } from '@syncfusion/ej2-base';
8+
9+
registerLicense('ORg4AjUWIQA/Gnt2U1hhQlJBfVddXHxLflFyVWtTfl16d1FWESFaRnZdRl1kSXtTfkdjW3dZdndV')
10+
11+
bootstrapApplication(AppComponent, appConfig)
12+
.catch((err) => console.error(err));

src/styles.css

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* You can add global styles to this file, and also import other style files */
2+
@import '../node_modules/@syncfusion/ej2-dropdowns/styles/material.css';
3+
@import '../node_modules/@syncfusion/ej2-base/styles/material.css';
4+
@import '../node_modules/@syncfusion/ej2-buttons/styles/material.css';
5+
6+
.container{
7+
margin-left: 550px;
8+
margin-top: 100px;
9+
width: 300px;
10+
}

0 commit comments

Comments
 (0)