Empty option is appearing because angular doesn't recognize the select's
ng-model in options list. Since 'e' is removed from options, angular
creates a dummy item in options list. This can be verified by inspecting
the select menu in developer tools. You will observe '?' in the empty
option's value. You will have to update the ng-model of select to a value
that exists in the options. For eg:
if (csep_string.indexOf($scope.sel_val) === -1) {
$scope.sel_val = csep_string[0];
}
Please refer to the following code in plnkr:
http://plnkr.co/edit/Fcmt18cThHeEIFNsUVJQ
However, your code might not be a production grade code as on each digest
cycle, "csep_to_list" function will be called. You might want to change the
itemList on input's update.
On Thursday, 22 October 2015 17:31:32 UTC+5:30, Sami Pietilä wrote:
>
> Hi,
>
> Please take a look at a simple angular test page:
> http://ariana.dy.fi/files/angular.html
>
> The select options are coming from the input field. If ",e" is erased from
> the input, two empty items appear to the selection options.
>
> How to write the code in such a way that empty values do not appear to the
> selection options?
>
> Thanks
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.