New to Angular here. I need to change the value of my hidden input 'cc_card' based on the first digit of the 'cc_number' input field. Ex. If a user types 5 in cc_number the hidden inputs value will be 'MasterCard', if a user types a 4 the hidden inputs value will be 'Visa' etc...
Here is my setup:
<div ng-app="" ng-init="prefixes={visa: '4', mastercard:'5', amex:'3', discover:'6'}" style="margin-bottom:25px;">
<div>
<h1>Payment details</h1>
</div>
<div>
<input name="cc_number" class="text-box" type="text" id="cc_number" value="" size="30" maxlength="30" required="required" placeholder="Credit card number" ng-model="prefixes.cards">
<input type="hidden" name="cc_card" id="cc_card" value="" />
</div>
<div>
<div>
<img id="visa" src="images/visa-card-logo.png" ng-class="{'greyed' : prefixes.cards.charAt(0) !== '4'}" />
</div>
<div>
<img id="mastercard" src="images/master-card-logo.png" ng-class="{'greyed' : prefixes.cards.charAt(0) !== '5'}" />
</div>
<div>
<img id="amex" src="images/amex-card-logo.png" ng-class="{'greyed' : prefixes.cards.charAt(0) !== '3'}" />
</div>
<div>
<img id="discover" src="images/discover-card-logo.png" ng-class="{'greyed' : prefixes.cards.charAt(0) !== '6'}" />
</div>
</div>
ngKeyuporngKeypressto trigger a function on a key event.. then do some checking and set your hidden fieldngModelto the hidden input, andngChangetocc_numberso when the value is changed you can set a value to the hidden input from the controller