ng-model inside an ng-repeat

Asked

Viewed 20 times

0

I tested several answers I found here, but nothing solved.

Each dataSample.name generates a line, with a SELECT with other options:

Example:

dataSample

exame sangue  -------  select -> tipo_de_tubo 1 / tipo_de_tubo_2 / tipo_de_tubo3

exame urina  -------  select -> tipo_de_tubo 1 / tipo_de_tubo_2 / tipo_de_tubo3

What happens is, when I select the type of tube from any of the exams, it repeats to all the other Selects.

  <div layout="column" class="mt-20">
    <div layout-gt-xs="row" class="data-row" ng-repeat="dataSample in BioBanco.content.data_sample" ng-model="BioBanco.data">
        <div flex-gt-xs>
          <md-checkbox >
              @{{dataSample.name}}
          </md-checkbox>
        </div>
        
        <div layout-gt-xs>
          <ng-md-icon  icon="opacity"  class="@{{dataSample.slug}}-1"   ng-click="BioBanco.tube(dataSample.slug, 1)" size="24"></ng-md-icon>
          <ng-md-icon  icon="opacity"  class="@{{dataSample.slug}}-2"   ng-click="BioBanco.tube(dataSample.slug, 2)" size="24"></ng-md-icon>
          <ng-md-icon  icon="opacity"  class="@{{dataSample.slug}}-3"   ng-click="BioBanco.tube(dataSample.slug, 3)" size="24"></ng-md-icon>
          <ng-md-icon  icon="opacity"  class="@{{dataSample.slug}}-4"   ng-click="BioBanco.tube(dataSample.slug, 4)" size="24"></ng-md-icon>
          <md-input-container  flex-gt-xs   class="component-render tube-type ">
          <md-tooltip md-direction="top" >Informar Quantidade e Tipo de Tubo</md-tooltip>
            <md-select ng-model="Biobanco.data.tube" aria-label="sexo do paciente"> 
              <md-option value="Citrato">                Citrato</md-option>
              <md-option value="EDTA">                   EDTA</md-option>
              <md-option value="Fluoreto de Sódio">      Fluoreto de Sódio</md-option>
              <md-option value="Heparina">               Heparina</md-option>
              <md-option value="Seco com Gel Reparador"> Seco com Gel Reparador</md-option>
              <md-option value="Sem Conservante">        Sem Conservante</md-option>
              <md-option value="RNA-Later">              RNA-Later</md-option>
              <md-option value="RNA/DNA Reag Estab">     RNA/DNA Reagente Estabilizante</md-option>
              <md-option value="Outros tubos">           Outros</md-option>
            </md-select>
          </md-input-container>
        </div>

        <div layout-gt-xs="row" > 
          <md-input-container  flex-gt-xs class="tube-type after">
          <span class="md-title label">Obs.:</span>
            <input  aria-label="observação" type="text"> 
          </md-input-container>
        </div>
        
    </div>
  </div>
  • you are using the msm ng-model="Biobanco.data.Tube" for everyone within the repeat this will make the value always the msm for everyone is as if you are duplicating the element and not creating new ones. try to change its value. to ng-model="Biobanco.data.tube1 ng-model="Biobanco.data.tube2 etc

  • That doesn’t work unless I put in a dynamic ng-model that gets Biobanco.data.Tube.Slug, but I couldn’t find a way to do that..

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.