0

複製字符串我在HTML下面的代碼:允許在陣列

<div class="col-sm-8"> 
     <div class="row col-sm-12 pull-right paddingDiv"> 
      <div class="col-sm-12"> 
       <div class="marginBottom pull-right"> 
        <button class="btn btn-default btn-xs"> 
         <i class="glyphicon glyphicon-remove"></i> 
        </button> 
        <button class="btn btn-default btn-xs"> 
         <i class="glyphicon glyphicon-edit"></i> 
        </button> 
        <button class="btn btn-default btn-xs" 
          ng-click="wsdlURLs.push('');"> 
         <i class="glyphicon glyphicon-plus"></i> 
        </button> 
       </div> 
       <div class="row"> 
        <div class="col-sm-12 marginBottom"> 
         <input ng-repeat="param in wsdlURLs" 
           type="text" 
           ng-model="param" 
           class="form-control"> 
        </div> 
       </div> 
      </div> 
     </div> 
    </div> 

我試圖做以下,如果我點擊+按鈕,它會添加一個空白字符串wsdlURLs ,它會在它下面添加一個(textBox),並且textBox將被綁定到wsdlURLs中的特定參數,我得到了錯誤!

  • 結合不工作在陣列(wsdlURLs)
  • 仿型

I need to do like this

任何一個可以幫助我嗎? 感謝

+1

「的軌道」? –

+0

http://plnkr.co/edit/stkEZ3RUUhtahCcx7Lvs?p=preview –

回答

1

嘗試$指數

<input ng-repeat="param in wsdlURLs" 
    type="url" 
    ng-model="wsdlURLs[$index]" 
    class="form-control"> 

您還可以使用類= 「URL」,這樣的角度,如果您的網址是有效的將驗證!

ngRepeat不允許重複鍵,這樣你就可以創建這個plunker您必須使用

ng-repeat="param in wsdlURLs track by $index" 
+0

好,那麼重複? –

+1

ng-repeat不允許重複鍵。所以,你只需要像這樣使用「track by」:ng-repeat =「param in wsdlURLs track by $ index」 –

+0

好! ... 萬分感謝 –