简体   繁体   中英

How to hide option value using ng-if condition in Angular JS

I have an Input form. The two input fields that I want to compare and display values if condition true. input fields are :-

<td class="td_label"><label>Client Age :</label></td>
<td class="td_input"><input type="text" required="required" class="age" ng-model="age" name="age" maxlength="2">                          
</td>
<td class="td_label"><label>Test Age :</label></td>
<td class="td_input"><input type="number" required="required" class="libr" ng-model="libr" name="libr"  min="50" max="100">                       
</td>

<td class="td_label"><label>Rider Cost :</label></td>
<td class="td_select"><select ng-model="rider" name="rider" required>
    <option value="">Please Select</option>
    <option value="0.0001">Option 1 - 3% No Rider</option>
    <option  value=".75">Option 2 - IAV 5.5% Rider .75%</option>
    <option value=".9">Option 3 - IAV 6.0% Rider .90%</option>
    <option value=".85">Option 4 - IAV 5.5% Rider .85%</option>
    <option value="1.0">Option 5 - IAV 6.0% Rider 1.0%</option>
</select></td> 

Now, I want my 3rd option from select option will not applicable if difference test age - age is more than 10 . what can i do ?

在这种情况下,您可以简单地使用ngHide

<option value=".9" ng-hide="libr && age && (libr - age > 10)">Option 3 - IAV 6.0% Rider .90%</option>

try this

 <option ng-disabled="age >= 10" value=".9">Option 3 - IAV 6.0% Rider .90%</option>

here is the working fiddle

只需对要隐藏的DOM使用ng-hide="age - libr > 10"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM