Ranjeet singh Ranjeet singh - 1 year ago 46
AngularJS Question

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 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 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>

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 ?

Answer Source

You can simply use ngHide in this case:

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