Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/syncfusionexamples/ej2-ng-dropdownlist-dynamic-itemtemplate
- Owner: SyncfusionExamples
- License: mit
- Created: 2018-01-09T11:36:28.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-21T04:55:04.000Z (3 months ago)
- Last Synced: 2024-10-21T07:47:50.948Z (3 months ago)
- Topics: dropdownlist, ej2, ej2-dropdown, itemtemplate, programmatically, template
- Language: TypeScript
- Size: 23.4 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
```