0
下面是我的代码,我有3个输入和一个视图按钮,点击查看时,我将从服务器获取数据。 3个输入是客户,日期,班次,我将这3个输入保存在一个ng-repeat中,以重复我拥有的客户数量。如果的customerID = 1,则NG-模式自定义输入也为1吴重复ng重复问题
<div ng-repeat = "x in CustomerList">
<form class="form-horizontal" ng-submit="getproductiondetails()">
<div class="form-group">
<div class="row">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-users"></i></span>
<select required class="form-control" ng-value= "x.customerID" ng-model="data.CustomerID">
</select>
</div>
<div class="input-group">
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="open1()"><i class="glyphicon glyphicon-calendar"></i></button>
</span>
<input type="text" class="form-control" uib-datepicker-popup="dd-MMM-yyyy" ng-model="data.ProductionReportDate" is-open="popup1.opened" required close-text="Close" />
</div>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-mars"></i></span>
<select required class="form-control" ng-model="data.ShiftTypeID">
<option value="">Shift</option>
<option ng-repeat="y in shiftList" value="{{y.ShiftTypeID}}">{{y.ShiftTypeName}}</option>
</select>
</div>
</div>
<div class="row">
<div class="col-md-2 pull-left">
<button type="submit" class="btn btn-primary">View</button>
</div>
</div>
</div>
</form>
</div>
但这里NG-模型在客户输入它没有选择时的customerID值。 如何让客户输入从ng-repeat中选择customerID值?
在CustomerList示例数据:
- 客户id = 1,客户名称= KL
- 客户id = 2,客户名称= JK在ShiftList
示例数据:
- ShiftID = 1,ShiftName =第一偏移
- ShiftID = 2,ShiftName = 2nd Shift
对不起它的角度 – Ranger
也许它应该是'ng-model =“x.ShiftTypeID”'而不是'ng-model =“data.ShiftTypeID”'?并且你应该避免使用相同的中继器别名(在选项中为'ng-repeat =“x in shiftList”',CustomerList中为'ng-repeat =“x)( –
对于初学者,ng-repeat =”CustomerList“ '和'ng-repeat =“x in shiftList”'共享它可能不喜欢的变量'x' –