无法为ng重复形式的每次迭代绑定单选值onclick函数

时间:2018-06-28 14:31:28

标签: angularjs

var aaa = angular.module("Module", [])
aaa.controller("Controller", function($scope, $filter, $timeout, $http, jsonFilter) {
$scope.SalaryData = [];
  $scope.addSalaryField = function() {
    $scope.SalaryData.push({});
  }

  $scope.first = function(abc) {
    $scope.salry.abc = $scope.abc;
  }
});
<!DOCTYPE html>
<html lang="en">
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
</head>
<body data-ng-app="Module" data-ng-controller="Controller">
  <form role="form" id="SalaryInfoForm" name="SalaryInfoForm" autocomplete="off" enctype="multipart/form-data" novalidate="">
    <div ng-repeat="salry in SalaryData">
      <p>Salary Given</p>
      	<div class="tabbable-panel">
	    <div class="tabbable-line">
			<ul class="nav nav-tabs ">
				<li class="active"><a href="#tab_default_1" data-toggle="tab" data-ng-click="first(salry.abc)" style="padding:10px 55px 10px 15px">Yes </a></li>
				<li><a href="#tab_default_2" data-toggle="tab" data-ng-click="first(salry.abc)" style="padding:10px 15px 10px 55px">No </a></li>
			</ul>
	    </div>
		</div>
      <input type="radio" name="abc" id="abc"  ng-model="salry.abc" value="Yes">Yes
      <input type="radio" name="abc" id="abc"  ng-model="salry.abc" value="No">No
    </div>
    <a data-ng-click="addSalaryField()">SAVE & ADD MORE</a>
  </form>
</body>
</html>

我在这里使用onclick addSalaryField()函数重复div。单击选项卡面板中first()函数的每个迭代时,应将值分配给radio ng-model。没用请帮助我们。我们需要在每次迭代中将值提取到ng-model

0 个答案:

没有答案