empty option in ng-model
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2017 06:29 AM
hello ,
the first time i want to select from my select option i found an empty record that i don't know from where his comes, i checked my function and there is no empty record
this is my select:
and there is the data.currentContact :
and this is the result i got :
any ideas pls ,
thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2017 01:25 PM
Hey Soukayna,
What is the end result here, just to not have the empty option?
The select box is being populated by the options. What is in data.contacts?
If you try the widget and save a record with that blank option and look at the XML of the new record what does the field show? Is it truly a blank? Is there a sys_id with no display value?
Let us know and we can try and help you further!
Best,
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2017 12:59 AM
hi andrew,
the data.contacts contains my contacts with some rules , i chekced this resulat and it doesn't contain an empty records and when i choose on of the list this empty field dissapear
thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2017 01:27 AM
I believe this happens because your ng-model (data.currentContract) is currently empty.
See this:
Why does AngularJS include an empty option in select? - Stack Overflow
The empty option is generated when a value referenced by ng-model doesn't exist in a set of options passed to ng-options. This happens to prevent accidental model selection: AngularJS can see that the initial model is either undefined or not in the set of options and don't want to decide model value on its own.
In short: the empty option means that no valid model is selected (by valid I mean: from the set of options). You need to select a valid model value to get rid of this empty option.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
I am having the same issue, did you manage to resolve it?