1
votes

hey everyone am trying to get the select value in a select input an am getting trouble with getting the selected value , i have a ng-repeat so i can add an item to each row in the selected row here's my code

 <li class="list-group-item" ng-repeat="l in list " >   

 <div class="row">
 <div class="col-md-8">

<h5>{{l}} : </h5>
</div>

 <div class="col-md-4" > 
        <div class="input-group">
        <select  ng-model="yy" ng-change="fct(yy,$index)" class="form-control">
        <option  value=""  selected>Not Passed</option>
        <option  value="passed"  >Passed</option>
        <option  value="ok"  >Ok</option>
        <option  value="ko"  >Ko</option>
        </select> 
         <span class="input-group-btn" ><button  id="{{$index}}"  type="submit" class="btn btn-primary form-control" data-toggle="collapse" disabled="disabled" data-target="#mycollapse_{{$index}}">
  <i class="glyphicon glyphicon-chevron-down"></i>
  </button></span>


        </div>

</div>

</div>  
<div id="mycollapse_{{$index}}" class="collapse">   
        <br>
        <div class="row">
        <div class="col-md-8">
        <div class="input-group"> 
        <input type="text" ng-model="bugfct" class="form-control" placeholder="Veuillez saisir le numéro de Bug :">          
     <span class="input-group-btn" ><button type=submit ng-click="bugfcts()" class="btn btn-success form-control"><i class="glyphicon glyphicon-ok"></i>
 </button></span>
        </div>                      
        </div>
        </div>
        <br>
 </li>  


    <button type="submit" ng-click=validate(yy) class="btn btn-success" >Valider</button>

here's my functions for the disabled button it doesn't work properly as you can see am passing the ng-model through the ng-change function

$scope.fct=function(x,index){

if(x=="ko")
document.getElementById(index).disabled=false;

else

document.getElementById(index).disabled=true ;
}

and here's the function to post the data it still empty but i console.log the ng-model=yy of the selected am getting undefined even if i select something

$scope.validate=function(eee){

console.log($scope.eee)
console.log($scope.yy)
console.log($scope.vin)
console.log($scope.trace)

}

here's an image to clear more the issue enter image description here

1

1 Answers

2
votes

you need define model for each select, use $index as key

    <div class="input-group">
    <select  ng-model="yy[$index]" ng-change="fct(yy,$index)" class="form-control">
    <option  value=""  selected>Not Passed</option>
    <option  value="passed"  >Passed</option>
    <option  value="ok"  >Ok</option>
    <option  value="ko"  >Ko</option>
    </select>