I am using select field from ui-select library. I am able to select the options or enter a new one. When I enter a new one and try to edit it by clicking on the field again the manually entered value is gone. Is there anyway available so that I can retain the manually entered value and at the same time edit it as well. I have referred the following stackoverflow question for implementing it. Allow manually entered text in ui-select
HTML
<ui-select ng-model="superhero.selected">
<ui-select-match placeholder="Select or search a superhero ...">{{$select.selected}}</ui-select-match>
<ui-select-choices repeat="hero in getSuperheroes($select.search) | filter: $select.search">
<div ng-bind="hero"></div>
</ui-select-choices>
</ui-select>
Controller
$scope.getSuperheroes = function(search) {
var newSupes = $scope.superheroes.slice();
if (search && newSupes.indexOf(search) === -1) {
newSupes.unshift(search);
}
return newSupes;
}
There is already a working codepen solution at the following link https://codepen.io/arcotnaresh/pen/bVqqdj