How to set default value for PrimeNG p-dropdown

后端 未结 8 1078
南笙
南笙 2020-12-09 17:53

I am using PrimeNG in my angular5 app. I have issue with p-dropdown

Question

I have p-dropdown for showing countries. I bind the select opti

8条回答
  •  自闭症患者
    2020-12-09 18:45

    You can set default value of PrimeNG Dropdown by using ngModel as shown on the following approach:


    component.html:

    
    


    component.ts:

    selectedCity: string = 1; //Id value of the City to be selected
    


    If it is not fixed due to version problems, try this:

    this.cities.value = this.selectedCity;  
    

    Hope this helps...

提交回复
热议问题