以表格形式显示数据。我希望在下载更改时获得兄弟姐妹的输入值。
<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>
我们怎样才能得到它。
答案 0 :(得分: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>
答案 1 :(得分:0)
我只是试着对你的问题进行回答。由于描述不多,这可能会有所不同。因此,如果这对您不起作用,请提供更多代码详细信息 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>
<强>控制器强>
$scope.callMe = function(index){
console.log(this.hdnInput[index]);
}