2015-12-10 54 views
1

嗨我有一個窗體,我無法禁用提交按鈕,如果字段爲空。以下是可以幫助我理解可能存在問題的代碼嗎?按鈕不是禁用使用ng禁用

<modal title="Add Navigation" visible="showAddModal"> 
    <form id="addform" class="form-horizontal"> 
     <div class="modal-body"> 
     <div ng-classs="form-group"> 
      <label class="col-sm-2 control-label">Client Type</label> 
      <div class="col-sm-10"> 
      <select name="account" class="form-control m-b w-md" ng-model="navData.clientType" ng-required="true"> 
       <option value="android">Android</option> 
       <option value="ios">iOs</option> 
      </select> 
      </div> 
     </div> 
     <div class="form-group"> 
      <label class="col-sm-2 control-label">Client Version</label> 
      <div class="col-sm-10"> 
      <input type="text" class="form-control w-md" ng-model="navData.clientVersion" placeholder="" required>       
      </div> 
     </div> 
     <div class="form-group"> 
      <label class="col-sm-2 control-label">Key Word</label> 
      <div class="col-sm-10"> 
      <input type="text" class="form-control w-md" ng-model="navData.keyWord" placeholder="" required>       
      </div> 
     </div> 
     <div class="form-group"> 
      <label class="col-sm-2 control-label">Value </label> 
      <div class="col-sm-10"> 
      <input type="text" class="form-control w-md" ng-model="navData.value" placeholder="" required>       
      </div> 
     </div> 
     </div> 
     <div class="modal-footer">     
      <button class="btn btn-default" data-dismiss="modal">Cancel</button> 
      <button class="btn btn-primary" ng-disabled="addform.$invalid" ng-click="addNav()">Add</button> 
     </div> 
    </form> 
    </modal> 
+0

可能'$ scope.addform $ invalid'不在過程中修改? – Rolice

+1

我認爲'addform。$ invalid'條件引用了一個名爲'name =「addform」'而不是'id =「addform」的表單' – Aaron

+0

@ Aaron是的,你說的很對,謝謝 –

回答