Ng-reapeat selects input of all forms change together

0

Hello,

I'm new to AngularJS, and I'm having trouble with ng-repeat:

The user can insert a portion of a form as many times as he wants, but in each one of them it should be possible to select different options.

I put the ng-reapet, but it happens that the option that I select in any of the replicated excerpts automatically changes the other selects of the other exits as well

link

<div ng-app="icmssProdutos" ng-controller="IcmssProdutosController">
  <div ng-repeat="icms in ICMSs">
    <div class="jumbotron">
      <label for="ex2">Regime</label>
      <select class="form-control" ng-model="selected.regime" ng-options="r.regime for r in data">
        <option value="">Selecione o Regime</option>
      </select>
      <label for="ex2" ng-show="selected.regime">Situação Tributária
        <select class="form-control" ng-show="selected.regime" ng-model="selected.situacao" ng-options="s.situacao for s in selected.regime.SituacaoTributaria">
          <option value="">Selecione a Situação Tributária</option>
        </select>
      </label>
      <label for="ex2" ng-show="selected.regime">Origem
        <select class="form-control" ng-model="selected.Origem" ng-options="o.Origem for o in selected.regime.Origens">
          <option value="">Selecione a Origem do Produto</option>
        </select>
      </label>
    </div>
  </div>

  <button type="button" class="btn btn-warning" ng-click="IncluirICMS()">INCLUIR</button>
</div>

How to solve this?

    
asked by anonymous 05.05.2016 / 15:56

1 answer

0

According to the link that was passed, all ICMS were operating on the same object, the < strong> selected . To solve the problem, simply remove the selected (which is unnecessary in this case), and take advantage of the ng-repeat icms variable. Thus each will operate with its object. Here is the solution:

link

    
05.05.2016 / 17:29