Skip to content

Instantly share code, notes, and snippets.

@kamikaz1k
Created July 23, 2016 15:50
Show Gist options
  • Save kamikaz1k/64e4f73337380fe168b207364d6f5649 to your computer and use it in GitHub Desktop.
Save kamikaz1k/64e4f73337380fe168b207364d6f5649 to your computer and use it in GitHub Desktop.
Phone Number component directive update
{
...
function validateInput (fieldId) {
if (/US|CA/.test(scope.countryCode)) { ... }
else { ... }
// Update internal update flag so that splitModel function
// knows that it was an internal trigger
directiveUpdate = true;
}
function splitModel() {
...
// If parentModel has no value
// check if the model was updated by the directive
// If it was, then don't clear the internal model
else if (!directiveUpdate) {
scope.phone.countryCode = "1";
scope.phone.areaCode = "";
scope.phone.phoneOne = "";
scope.phone.phoneTwo = "";
scope.phone.international = "";
}
// Reset the directive update flag
directiveUpdate = false;
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment