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,在模板引用中,我们需要这样引用。就是将首字母小写,每个名字部分首字母大写的形式转化为通过-来连接小写部分的形式。

命名的时候得注意这个隐含的转化规则,真是个坑


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部