Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/syncfusionexamples/ej2-ng-dropdownlist-dynamic-itemtemplate

DropDownList with dynamic itemTemplate for Angular
https://github.com/syncfusionexamples/ej2-ng-dropdownlist-dynamic-itemtemplate

dropdownlist ej2 ej2-dropdown itemtemplate programmatically template

Last synced: 24 days ago
JSON representation

DropDownList with dynamic itemTemplate for Angular

Awesome Lists containing this project

README

        

# DropDownList with dynamic itemTemplate for Angular

## To set the itemTemplate programmatically for dropdownlist component

To load an itemTemplate in the dropdownlist component dynamically, we need to use createComponent to load the template as new component and assign its itemTemplate instance to dropdownlist's itemTemplate property. Please refer the below code snippet,

```
ngAfterViewInit() {
let componentFactory = this.componentResolver.resolveComponentFactory(Newcomponent);
const ref = this.viewContainerRef.createComponent(componentFactory);
this.ddl.itemTemplate = ref.instance.itemTemplate;
}
```

## Installing and Running Application

### Installing

To install all dependent packages, use the below command

```
npm install
```

### Run the application

To compile and run the source files, use the below command

```
npm start
```