angularjs directive和component定名划定规矩的坑

angularjs directive和component定名划定规矩的坑

今天赋发明angularjs doc中directive有这么一段

Normalization Angular normalizes an element’s tag and attribute name
to determine which elements match which directives. We typically refer
to directives by their case-sensitive camelCase normalized name (e.g.
ngModel). However, since HTML is case-insensitive, we refer to
directives in the DOM by lower-case forms, typically using
dash-delimited attributes on DOM elements (e.g. ng-model).

The normalization process is as follows:

Strip x- and data- from the front of the element/attributes. Convert
the :, -, or _-delimited name to camelCase.

这段实在也讲了html定名转化划定规矩

比方我定义一个component名字为cpuLoad,在模板援用中,我们须要如许援用<cpu-load>。就是将首字母小写,每一个名字部份首字母大写的情势转化为经由过程-来衔接小写部份的情势。

定名的时刻得注重这个隐含的转化划定规矩,真是个坑

    原文作者:chenatu
    原文地址: https://segmentfault.com/a/1190000007018852
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞