0

Data display in table form. and i want to get siblings input value on dropdown onchange.

<tr ng-repeat="x in record">
          <td>{{x.company }}</td>
          <td>{{x.contact}}</td>
          <td>
          <input type='hidden' value="{{x.id}}">
          <select name='status' >
            <option value='1'>Active</option>
            <option value='0'>Inactive</option>
            </select> 
            </td>
      </tr>

How can we get it.

Deepak3301086
  • 447
  • 2
  • 23
  • Use `ng-change` – Saeed Apr 28 '18 at 05:01
  • You need to include an `ng-model` directive on both the `` and `` Dirertive API Reference](https://docs.angularjs.org/api/ng/directive/select) and the [AngularJS `` Directive API Reference](https://docs.angularjs.org/api/ng/directive/input). – georgeawg Apr 28 '18 at 05:09

2 Answers2

0

angular.module('app', []).controller('ctrl', function($scope) {
  $scope.record = [
    { company: 'Comp1', contact: 'Cont1', id: 1 },
    { company: 'Comp2', contact: 'Cont2', id: 2 }
  ]
  $scope.process = function(input) {
    console.log(input);
  }
})
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js">
</script>

<table ng-app='app' ng-controller='ctrl'>
  <tbody>
    <tr ng-repeat="x in record">
      <td>{{x.company }}</td>
      <td>{{x.contact}}</td>
      <td>
        <input type='hidden' ng-model='x.id' />
        <select name='status' ng-model='x.active' ng-change='process(x.id)'>
          <option value='1'>Active</option>
          <option value='0'>Inactive</option>
        </select>
      </td>
    </tr>
  </tbody>
</table>
Slava Utesinov
  • 13,410
  • 2
  • 19
  • 26
0

I just tryout to project answer over your question. This might some different because of little description. So provide more code detail if this will not get work for you.
HTML

<tr ng-repeat="x in record">
    <td>{{x.company }}</td>
    <td>{{x.contact}}</td>
    <td>
    <input type='hidden' value="{{x.id}}" ng-model="hdnInput">
    <select name='status' ng-model="status" ng-change="callMe($index)">
    <option value='1'>Active</option>
    <option value='0'>Inactive</option>
    </select> 
    </td>
</tr>

Controller

$scope.callMe = function(index){
    console.log(this.hdnInput[index]);
}
USS
  • 460
  • 4
  • 16