How to maintain state of a select?

0

It can be in jquery or angularjs help.

I have the following picklist (handmade):

<divclass="form group">
      <label class="control-label col-md-3">Selecionar Empresas:</label>
         <select id="select1" name="select1" multiple="multiple">
            <option ng-repeat="c in clientes" value="{{c.idCliente}}" ng-click="atribuirUm($index, c)">{{c.razaoSocial}}</option>                            
          </select>

         <select ng-model="listaEmpresas" id="select2" name="select2" multiple="multiple">
              <option selected="selected" ng-repeat="c2 in clientes2" value="{{c2.idCliente}}" ng-click="limparUm($index, c2)">{{c2.razaoSocial}}</option>                              
         </select>                               
 </div>

Before, I only needed the value in clients2 to work the data at other times.

Now, I need to keep the state of the first select and the second, whenever I load the page, I need to know what was left and right.

How can I with this code, adapt this? Any info is valid, thank you!

/**
 * Trabalhando o componente picklist
 */
$scope.clientes2 = [];      
$scope.atribuirUm = function(index, c) {
    var cliente = {};
    cliente.idCliente = c.idCliente;
    cliente.razaoSocial = c.razaoSocial;
    $scope.clientes2.push(cliente);
    $scope.clientes.splice(index, 1);
};
$scope.limparUm = function(index, c2) {
    $scope.clientes2.splice(index, 1);
    $scope.clientes.push(c2);       
};
    
asked by anonymous 01.02.2016 / 19:41

0 answers