Search filter combobox AngularJS

0

I have SELECT multiple with the options for query, but when I select an item does not return anything, if someone can give a force I thank.

/* Retorna operadoras */
$scope.operadoras = [{
    nome: "CLARO"
  },
  {
    nome: "TIM"
  },
  {
    nome: "VIVO"
  },
  {
    nome: "OI"
  },
  {
    nome: "NEXTEL"
  }
];

$scope.filtroOperadora = function() {
  return ($scope.operadoras == busca.nome);
}
<div class="form-group col-md-2 input-group-sm mb-3">
  <label for="exampleInputPassword1" class="text-sm font-weight-bold">Operadora</label>
  <select class="form-control seleciona text-sm" multiple name="prospectOperadora" data-width="100%" ng-model="busca">
    <option value="">Selecione</option>
    <option ng-repeat="oper in operadoras" value="{{oper.nome}}">
      {{oper.nome}}
    </option>
  </select>
</div>

<li style="font-size: 13px; padding:10px;" ng-repeat="prospect in listaProspect | orderBy: 'prospectNome' | betweenDate:'prospeccaoPrevisao':startDate:endDate | filter:busca track by $index">
</li>
    
asked by anonymous 31.07.2018 / 23:17

2 answers

0

For the code you entered, you can not complete much.

However, from what you put here:

$scope.filtroOperadora = function() {
  return ($scope.operadoras == busca.nome);
}

It does not make much sense, since users is an Array and search is probably a string.

I made a basic example here: link

However, since you can probably have an Array of strings you want to look up in the list of operators, here's another example: link

Abs.

    
01.08.2018 / 00:18
1

I decided to create an example, where information collation is done in SELECT with the multiple property:

var app = angular.module('app', []);
app.controller('ctrl', function($scope) {
  $scope.operadora = [];
  $scope.operadoras = [{
      nome: "CLARO"
    },
    {
      nome: "TIM"
    },
    {
      nome: "VIVO"
    },
    {
      nome: "OI"
    },
    {
      nome: "NEXTEL"
    }
  ];

  $scope.lista = [{
      nome: 'item 1',
      operadora: 'OI'
    },
    {
      nome: 'item 2',
      operadora: 'OI'
    },
    {
      nome: 'item 3',
      operadora: 'CLARO'
    },
    {
      nome: 'item 4',
      operadora: 'NEXTEL'
    },
    {
      nome: 'item 5',
      operadora: 'VIVO'
    },
    {
      nome: 'item 6',
      operadora: 'TIM'
    }
  ];

  $scope.listFilter = function(model) {    
    if ($scope.operadora.length == 0) return true;
    return $scope.operadora.indexOf(model.operadora) > -1;
  };
});
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/bootstrap-select.min.js"></script>

<div ng-app="app" ng-controller="ctrl">
  <select multiple ng-model="operadora" class="selectpicker">
    <option ng-repeat="o in operadoras" value="{{o.nome}}">{{o.nome}}</option>
  </select>
  <br /><br /><br />
  <ul>
    <li ng-repeat="i in lista  | filter:listFilter">
      {{i.nome}} {{i.operadora}}
    </li>
  </ul>
</div>

In this case need to create a custom filter , and search the array of information for the items that were selected no SELECT which is another array as well.

01.08.2018 / 00:15