Create your own scope at each ng-repeat iteration

1

I am trying to make a table of values to be filled and stored, line by line. However, even after the first row is filled and stored, when I change the value of a select, the select of all the lines above the one I am inserting are having their values changed.

Is it possible to isolate each line with its own scope?

Code:

 <tr class="odd" ng-repeat="itemSaida in vm.itensSaida"> 
                                <!-- SELECT DE PRODUTOS -->
                                <td class="expand">
                                     <span class="responsiveExpander">
                                         <select class="form-control" ng-disabled="itemSaida.id && !itemSaida.editando" ng-model="itemSaida.fkProduto" ng-options="produto.id as (produto.id + '-' + produto.nome) for produto in vm.produtos" ng-change="post('carregar-estoque/'+ itemSaida.fkProduto, {indice: $index})">
                                             <option value="">-- SELECIONE --</option>
                                         </select>
                                     </span>
                                </td>

                                <!-- Unidade -->
                                <td class="expand">
                                     <span class="responsiveExpander">
                                         <input type="text" class="form-control text-left" ng-disabled="true" auto-focus ng-model="vm.unidade">
                                     </span>
                                </td>

                               <!-- SELECT DE ESTOQUES -->
                               <td class="expand">
                                   <span class="responsiveExpander">
                                        <select class="form-control" ng-disabled="itemSaida.id && !itemSaida.editando" ng-model="itemSaida.fkEstoque" ng-options="fkEstoque.id as (fkEstoque.tipoEstoque.nome + ': Qtde:' + fkEstoque.quantidade) for fkEstoque in vm.estoques" ng-change="get('carregar-data-vencimento/'+itemSaida.fkEstoque)">
                                            <option value="">-- SELECIONE --</option>
                                        </select>
                                   </span>
                               </td>

                               <!-- Vencimento -->
                               <td class="expand">
                                    <span class="responsiveExpander">
                                        <input ng-model="vm.vencimento" mask="date" type="text" class="form-control text-left" ng-disabled="true" auto-focus>
                                    </span>
                               </td>

                               <td class="expand">
                                    <span class="responsiveExpander">
                                        <input type="text" class="form-control text-left" ng-disabled="itemSaida.id && !itemSaida.editando" ng-model="itemSaida.quantidade" id="quantidade" mask="decimal" maxlength="15" placeholder="Quantidade">
                                    </span>
                               </td>

To get a little simpler to understand: this is a list of items in which each row of a table will be responsible for registering an item. The figure below illustrates:

After saving the first item, when I go to select the product on the bottom line, it is updating the unit in both the top and bottom line, but the top should be the old value. This is happening because of the angular. A get request is made on the server, which updates the vm.unity variable, which ends up updating both lines.

    
asked by anonymous 01.09.2017 / 16:16

0 answers