Created
July 23, 2016 15:50
-
-
Save kamikaz1k/64e4f73337380fe168b207364d6f5649 to your computer and use it in GitHub Desktop.
Phone Number component directive update
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
... | |
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