We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

add dropdown Programmatically

I need to add same dropdowns programatically and add new ones when clicked Add new 




3 Replies 1 reply marked as answer

JM Jeyanth Muthu Pratheeban Sankara Subramanian Syncfusion Team July 30, 2020 02:51 PM UTC

Hi Vin,

Greetings from Syncfusion support.

We have checked your query. We can achieve this requirement using ngFor in Angular. We have made a simple sample which demonstrates your requirement. Please find the sample below.



Sample Link : https://stackblitz.com/edit/angular-kkumu5-xbgfcb?file=app.component.html

Screenshot:


 
 


Regards,
Jeyanth.



VI vin July 31, 2020 01:02 AM UTC

I am getting same values with your example
I need  different values for [(ngModel)]="value"




JM Jeyanth Muthu Pratheeban Sankara Subramanian Syncfusion Team July 31, 2020 08:45 AM UTC

Hi Vin,

Thanks for your update.

We suggest you to use ngModel if you are in need of two way binding. Also since we used ngFor, control will be refreshed on each time when the iterating variable is affected and based on the iterating variable for loop is executed which causes same value to display for all rendered controls. To overcome this, we suggest you to update the value of the dropdownlist in the created event which triggers when the control is created.

 
Screenshot:


 
onCreated(e,instance){ 
    (instance.element.ej2_instances[0as any).value = this.value; 
  } 

Jeyanth. 


Marked as answer
Loader.
Up arrow icon