optimistex / ngx-select-ex

Angular based replacement for select boxes
https://optimistex.github.io/ngx-select-ex/
MIT License
109 stars 42 forks source link

How to preserve option templates when Dynamically Created #177

Closed bmgarness closed 4 years ago

bmgarness commented 4 years ago

Describe the bug When Dynamically creating the ngx-select-component, I do not know how to set the template for Options.

To Reproduce Here's an example

https://stackblitz.com/edit/ngx-select-ex-scratch-fnrbs5

Expected behavior

I expected the template underneath ngx-select with the right directive to be also created.

optimistex commented 4 years ago

@bmgarness In your approach most probably this article could help you: https://blog.ng-book.com/dynamic-components-with-content-projection-in-angular/

Also, you could use *ngFor to produce new components. Usually I do this

optimistex commented 4 years ago

@bmgarness I've prepared an example for you for producing the select components via *ngFor: https://stackblitz.com/edit/ngx-select-ex-scratch-issues-177?file=src/app/app.component.html