I understand that Angular converts directive names from camel case to hyphen separated strings.
Is this functionality accessible through the API, like a function or something? I would like to convert some strings to hyphenated versions in my angular app and I don't want to reinvent the wheel if not necessary.
The function used can be found here
Unfortunately, it is not available through API.
lodash has method kebabCase that does exactly this.
I used the below code to convert the Camelcase string into directive name format.
myApp.filter(`con2directivename`,function(){
return function(name){
return name.replace(/([A-Z])/g, function($1){return "-"+$1.toLowerCase();});
};
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With