javascript - Ng-disabled button based on two different forms -


while working on project came across problem, needed disable button long 2 different tables (with ng-repeat in rows, in turn had required input per row) had empty fields still. basically:

<table class="table table-striped fontsize12"> <thead>     <tr>         <th class="width-desc-auto">description</th>         <th class="width-reg-auto">value</th>     </tr> </thead> <tbody>     <tr ng-repeat="item in items">         <td><h6>{{item.description}}</h6></td>         <td>             <input type="text" class="form-control" ng-model="item.value"                     placeholder="{{item.value}}" disabled="true" required             >         </td>     </tr> </tbody> 

and :

    <table class="table table-striped fontsize12"> <thead>     <tr>         <th class="width-desc-auto">description</th>         <th class="width-reg-auto">value</th>     </tr> </thead> <tbody>     <tr ng-repeat="char in chars">         <td><h6>{{char.description}}</h6></td>         <td>             <input type="text" class="form-control"               ng-model="char.value" placeholder="register value" required             >         </td>     </tr> </tbody> 

the first 1 being filled in automatically, still empty in cases , second 1 has input manually. actual arrays on repeat don't matter. right solved putting form tag surrounding both of tables , included button within form tag aswell.:

<form name="myform">      <table>...</table>      <table>...</table>      <span class="pull-right">          <button class="btn btn-sm btn-primary" type="button" ng-disabled="myform.$invalid">            close          </button>      </span> </form> 

this works, if needed both tables put in different form? example autoform , manualform? , need put actual button within form tag aswell? didn't seem work if put outside of it.

my apologies if has been asked before couldn't find it. ty in advance.

you don't need form tag long tables in same scope . can check values of both input fields in ng-disabled directive , disable accordingly example here can use

<button class="btn btn-sm btn-primary" type="button"          ng-disabled="!(item.value && char.value)" >   close </button> 

in case button enable when both input types filled


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -