docs: Style Guide's "Directive selectors" doesn't mention prefixing selectors
See original GitHub issueI’m submitting a…
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
In the Directive selectors section of the Style Guide, nothing is mentioned about prefixing selectors for name spacing.
However, in the Guide for Write a structural directive, in the second to last paragraph, you can find the following:
The directive attribute name should be spelled in lowerCamelCase and begin with a prefix. Don’t use
ng
. That prefix belongs to Angular. Pick something short that fits you or your company. In this example, the prefix isapp
.
This is not mentioned in the style guide. Worse, Angular’s directives seem to only be prefixed with ng
when it’s a “single word” directive—ngForm
—but they are not prefixed with they are multiple words—formControlName
.
Expected behavior
The Style Guide should make a recommendation about prefixing or not prefixing directive attribute names. I would be more than happy to submit a PR to clarify the issue in the Style Guide once I receive direction. 👍
Issue Analytics
- State:
- Created 6 years ago
- Comments:17 (16 by maintainers)
I have to admit I am not sure. I would imagine that a number people (and maybe tools) link through to these styles, so perhaps the numbering should stay stable.
So if I’m understanding correctly, this is how it should be reorganized:
In Naming, I think it makes sense for the Component section to appear before the Directive section as components are more common. Also, renaming Custom prefix for components to Component custom prefix keeps it visually connected to the preceding Component selectors.
If that sounds good I’ll submit a PR with those changes. 😄