Allow manually entered text in ui-select

后端 未结 5 593
北海茫月
北海茫月 2020-12-05 13:24

I am using a select box from ui-select. All is working fine, but I want to allow manually entered text and do not want to restrict the user from the values available in the

5条回答
  •  被撕碎了的回忆
    2020-12-05 14:02

    here is a solution:

    HTML -

    
      {{$select.selected}}
      
        

    CONTROLLER -

    $scope.getSuperheroes = function(search) {
     var newSupes = $scope.superheroes.slice();
      if (search && newSupes.indexOf(search) === -1) {
        newSupes.unshift(search);
      }
      return newSupes;
    }
    

    Here is the CodePen solution.

提交回复
热议问题