For angular custom directive the best practice is to follow camel
casing and that also with atleast two letter’s. In camel case naming
convention we start with a small letter, followed by a capital letter
for every word.
Some example of camel cases are “loopCounter” , “isValid” and so on.
So when you register a custom directive it should be with camel case format as shown in the below code “companyCopyRight”.
If you are making a one letter prefix like “copyright” it’s very much
possible that tomorrow if HTML team creates a tag with the same name,
it will clash with your custom directive. That’s why angular team
recommends camel case which inserts a “-“ in between to avoid further
collision with future HTML tag’s.
Some example of camel cases are “loopCounter” , “isValid” and so on.
So when you register a custom directive it should be with camel case format as shown in the below code “companyCopyRight”.
app.directive('companyCopyRight', function ()
{
return
{
template: '@CopyRight questpond.com '
};
});
Later when this directive is consumed inside HTML before each capital
letter of camel case we need to insert a “-“ as specified in the below
code.<div company-copy-right></div>

No comments:
Post a Comment