I have a directive for validating creditcard luhn, and length. As a validator of the number it works great. The algorithm used is based off of a jquery plugin (sans jquery) that also returns the card type to me. The ending result is something like
{
luhn_valid: true,
length_valid: true
card_type: {
name: 'visa'
}
}
So it gives me the card type name. I want to assign this to a different model variable so that I can pass both the card type and card number to REST api to add the card. The problem is I do not know how to access a model that is not declared associated with the directive.
<input type="text" name="cardNumber" ng-model="cardCtrl.form.inputs.cardNumber"
credit-card-validator card-type-model="cardCtrl.form.inputs.cardType">
In the example above I add an extra attribute to pass the model name to the directive. I have passed $scope to the directive and can see cardCtrl as a child of $scope, so I feel I should be able to get to the model from it, but I am not sure the best way to do it.
Thoughts on the best way to get access to this other model?
card-type-modeldeclared in your directive code?