2

When created the new Angular 1.5 or 2.0 components, should I still be prefixing the name of the component using 3 letters for example

 abc-my-component

abc being a name to avoid duplication with other components?

I was unsure if this is still necessary and I am not seeing a lot of use out in the wild.

What direction should I take?

halfer
  • 19,824
  • 17
  • 99
  • 186
Martin
  • 23,844
  • 55
  • 201
  • 327

2 Answers2

2

Angular 2 style guide says:

Do use a prefix that identifies the feature area or the app itself.

Also, you may wish to look at the Angular Material library (both v1 and v2). They were built as a cannoncial library of sorts. The components there all use the 'md' prefix.

GBa
  • 17,509
  • 15
  • 49
  • 67
2

This recommendation is from angular2 team

"We recommend picking a selector name with a prefix to ensure that it cannot conflict with any standard HTML attribute, now or in the future. There is also less risk of colliding with a third-party directive name when we give ours a prefix."

Keep using prefix will also make team know what is used in code quickly.

In my team, we use two types of prefix

Prefix as short name of company name for common ui components which we expect can be reuse in another projects in the future.

Prefix as short name of project name for business domain components of the project.

But we keep it short with max 3 letters for common ui components and 3 letters for business components.

Most ui components use it, for example igniteui with ig, ionic with ion, onsen ui with ons, ...

Vu Quyet
  • 1,675
  • 1
  • 16
  • 22