I am using PrimeNG to render my dynamic dropdown options. Based on the option value I don't want my ngModel to be udpated.
Let's say if my option is an object such as dropdownObject.canUpdateModel = true, then I want my ngModel to be updated, if not ngModel should not be updated. Can someone please help me with this.
<p-dropdown #dp [options]="myList"(onChange)="onFMyDropdownChange(selectedForeCast)"[(ngModel)]="selectedForeCast"></p-dropdown>
Use getter/setter approach, so you will be able to intercept attempt to set new value to model - inspect the value for given criteria - and assignt to model or reject the change.
It would be something like this
get selectedForeCast(){
return whateverModelValue;
}
set selectedForeCast(selectedValue){
if(selectedValue whatever here){
whateverModelValue=selectedValue;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.