角指令名:只允许小写字母?

编程入门 行业动态 更新时间:2024-10-27 18:23:48
本文介绍了角指令名:只允许小写字母?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的code:

app.directive('abcabc', function (){ alert('directive');}); // working

app.directive('abcAbc', function (){ alert('directive');}); // not working ! app.directive('abc-abc', function (){ alert('directive');}); // not working !

难道我做错了吗?或者有折角指令特殊的命名规则?

Am I doing wrong? Or there are special naming rules for Angular directive?

推荐答案

AngularJS试图让所有人都满意!

AngularJS attempts to make everyone happy!

有人preFER使用数据的属性,如数据-ABC-ABC ,我想保持验证高兴。其他人preFER使用的命名空间,比如 ABC:ABC ,和其他preFER使用实际的指令名 ABCABC 。甚至全部大写 ABC_ABC 。或扩展属性,如 X-ABC-ABC 。

Some people prefer to use data attributes, like data-abc-abc, I assume to keep validators happy. Other people prefer to use namespaces like abc:abc, and others prefer to use the actual directive name abcAbc. Or even all caps ABC_ABC. Or extension attributes like x-abc-abc.

AngularJS正常化在HTML中用于试图覆盖所有这些情况的名称。 数据 - 和 X - 被剥离时,用驼峰格式余:, - 和 _ 的字边界。这使得 ABCABC 从上面提到的情况,这是用来查找在JavaScript中声明的指令。

AngularJS normalises the name used in HTML to attempt to cover all of these cases. data- and x- are stripped, the remainder camelcased with :, - and _ as word boundaries. This makes abcAbc from the cases mentioned above, which is used to look up the directive declared in JavaScript.

这是所有所谓的属性归(美国:属性正常化),并可以在 AngularJS文档中找到和source code 。

This is all called attribute normalisation (US: attribute normalization) and can be found in the AngularJS documentation and source code.

更多推荐

角指令名:只允许小写字母?

本文发布于:2023-10-16 17:05:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1498195.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:指令   只允许   字母

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!