Hi I think your directive is really helpful.
However, I had some requirements in terms of how it would behave for example I wanted different display for different naming type:
uttesh Ranjit UR
Aidan Vandier Sat ==> AV
Gael Magma Do Borneo ==> GM
Adrian Di Bisumbio ==> AB
Antoine ==> AN
Antoine Kouroki ==> AK
Adrien Kou ==> AK
for that I built and tested this function:
function determineCharacterNumbers(isMultiple, avatarData, charCount){
var words = [],
valReturn = null;
if(!isMultiple){
valReturn = avatarData.substr(0, charCount).toUpperCase();
}
else{
words = avatarData.split(" ");
for (var i = 0; i < words.length; i++) {
if(words.length >= 2){
// we pop particle names "De", "Of", "The", "Van" etc...
if((i != 0) && ( words[i].length === 2 || words[i].length === 3)){
if(i != words.length - 1){
words.splice(i,1);
}
}
words[i] = words[i].substr(0,1).toUpperCase();
}
};
// we add something like ['A', 'V'] that becomes AV
valReturn = words.join('').substr(0, charCount).toUpperCase();
}
return valReturn;
}
// and in the link function
var c = determineCharacterNumbers(params.multiWord, params.data, params.charCount);
The code might not be the most efficient but it does the job, if you are okay with it I was wondering if it could be added to your directive?
Hi I think your directive is really helpful. However, I had some requirements in terms of how it would behave for example I wanted different display for different naming type:
The code might not be the most efficient but it does the job, if you are okay with it I was wondering if it could be added to your directive?