2017-02-14 114 views
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示例数据:

  1. 客户id = 1,客户名称= KL
  2. 客户id = 2,客户名称= JK在ShiftList

示例数据:

  1. ShiftID = 1,ShiftName =第一偏移
  2. ShiftID = 2,ShiftName = 2nd Shift
+0

对不起它的角度 – Ranger

+0

也许它应该是'ng-model =“x.ShiftTypeID”'而不是'ng-model =“data.ShiftTypeID”'?并且你应该避免使用相同的中继器别名(在选项中为'ng-repeat =“x in shiftList”',CustomerList中为'ng-repeat =“x)( –

+0

对于初学者,ng-repeat =”CustomerList“ '和'ng-repeat =“x in shiftList”'共享它可能不喜欢的变量'x' –

回答

0

你应该重复一个表单吗?你能否重复并显示数值? 在每一行上都可以有编辑按钮。按下该按钮可以进入编辑模式。我喜欢划分视图模式和编辑模式。注意:如果您想在此时编辑一行,则需要为“SINGLE”行对象提供服务器PUT/PATCH资源。请回复,如果你想要一个简单的例子