Why does Angular not need a dash in component name

前端 未结 2 1088
猫巷女王i
猫巷女王i 2021-01-01 18:31

I wondered why Polymer elements need a dash in custom elements name like while this is not necessary for Angular components especially as A

2条回答
  •  不知归路
    2021-01-01 18:50

    The dash is not required by Angular since there is no technical reason to require it. However, all large projects I have worked on prefix all components and directives with a two character and then dash prefix, e.g "ab-tab".

    First, using dashes in names makes your syntax compatible with the Custom Elements standard, although Angular doesn't depending the spec.

    Second, it helps with organization. Standard Angular directives are all prefixed with 'ng-'. By using your own prefix, people reading your code will be able to quickly distinguish between components from different libraries.

提交回复
热议问题