When trying to generate a component using the Angular 6 CLI (version 6.0.7), I encountered an issue. After typing in ng g c t1-2-3-user
, I received an error message stating that the selector (app-t1-2-3-user
) is invalid.
I wondered if there was something inherent about this name that was not allowed by Angular. Interestingly, I had previously created a parent module named t1-myModule
using ng g module t1-myModule
without any issues. The problem seems to be specific to naming a component as t1-2-3-user
within that module.
To test this hypothesis, I tried creating a different component with the command ng g c t1-testComponent
and it worked perfectly. So, it appears that the CLI is functioning properly, but there may be some restriction on naming conventions for components like t1-2-3-user
in Angular.
EDIT: Upon further investigation, I discovered that Angular dislikes having a number as the first character after a dash (-
) in a component name. This limitation might be similar to restrictions found in JavaScript variables, considering that Angular eventually compiles into JavaScript. Can anyone provide more insight or confirm this constraint on component naming?