2017-02-14 115 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資源。請回復,如果你想要一個簡單的例子