I have this following code:
我有以下代码:
<div class="table-responsive" ng-if="form.productDetails != false">
<table class="table table-striped table-condensed table-hover">
<thead>
<tr class="small">
<th class="col-xs-1">Name of Product/th>
<th class="col-xs-1">Price</th>
<th class="col-xs-1">Actions</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="productDetails in form.productDetails.item">
<td ng-form="prductForm"><input type="hidden" name="productDetails" required ng-model="form.mainProductDetails.productDetails" ng-value="{{productDetails.name}}"></td>
<td>{{productDetails.name}}</td>
<td>{{productDetails.price}}</td>
<td>
<button type="button" class="btn btn-xs btn-primary" ng-click="editProduct(productDetails)"><i class="glyphicon glyphicon-pencil"></i> Edit</button>
<button type="button" class="btn btn-xs btn-danger" ng-click="removeProduct(productDetails)"><i class="glyphicon glyphicon-trash"></i> Delete</button>
</td>
</tr>
</tbody>
</table>
</div>
Now I want to make the table or the columns required and table will be only validate if there is any data exists in the table columns.
现在,我要使表或列成为必需的,并且只有在表列中存在任何数据时,表才会被验证。
I have added this hidden input field which needs to be required. based on data passed from ng-repeat the validation should be done.
我添加了这个需要的隐藏输入字段。根据从ng-repeat传递的数据进行验证。
I have seen many examples but not quite sure how to solve this. Thanks in advance.
我见过很多例子,但不太确定如何解决这个问题。提前谢谢。
1 个解决方案
#1
0
Have you tried using ng-required in angularjs ? ng-required is to set an input field to required or not required dynamically. Also if possible could you share your code online so that I understand the problem statement properly.
你试过在angularjs中使用ng-required吗?ng-required是动态地将输入字段设置为required或not required。如果可能的话,您可以在网上共享您的代码,以便我正确地理解问题声明。
#1
0
Have you tried using ng-required in angularjs ? ng-required is to set an input field to required or not required dynamically. Also if possible could you share your code online so that I understand the problem statement properly.
你试过在angularjs中使用ng-required吗?ng-required是动态地将输入字段设置为required或not required。如果可能的话,您可以在网上共享您的代码,以便我正确地理解问题声明。