e-Designary e-Designary - 6 months ago 27
AngularJS Question

Show input field based on ng-if condition

I've two radio buttons VAT & CST and one input field. If I select VAT the input field should appear and if I select input field should be hidden. How to do it in angularJS. Thank You!

Here is my code

<input type="radio" ng-model="vat" name="source" value="VAT"> VAT
<input type="radio" name="source" value="CST"> CST

<input type="number" ng-if="vat" placeholder="Gunny VAT">


Use ng-model.

<input type="radio" ng-model="flag" name="source" value="VAT"> VAT
<input type="radio" ng-model="flag" name="source" value="CST"> CST

<input type="number" ng-if="flag == 'VAT'" placeholder="Gunny VAT">