问题描述
我想使用 on-drag-start
作为 AngularJS 指令中的一个属性,称为 ngDraggable
.
但是,似乎不可能具有该属性.
I wanted to use on-drag-start
as an attribute in AngularJS directive, called ngDraggable
.
However, it seems not possible to have that attribute.
以下代码是纯javascript,我可以获取on-drag-start
作为属性.我认为无论属性名称如何,我都可以获得任何属性.
The following code is in pure javascript, and I can get on-drag-start
as an attribute.I think I can get any attribute regardless of attribute name.
<h1 id="tag1" on-drag-start="START" on-drag="DRAG" on-drag-end="END" >Hello Plunker!</h1>
纯 javasctipt 演示中的属性:http://plnkr.co/edit/6iODSnf56KtwPFpoC7ck?p=preview
Attributes in pure javasctipt DEMO: http://plnkr.co/edit/6iODSnf56KtwPFpoC7ck?p=preview
但是,在 AngularjS 的以下代码中,我无法将 onDragStart
作为属性获取,但可以将 onDragBegin
作为属性获取.
However, in the following code in AngularjS, I cannot get onDragStart
as an attribute, but it is possible to get onDragBegin
as an attribute.
<h1 id="tag1" ng-draggable on-drag="DRAG" on-drag-end="END"
on-drag-start="START" on-drag-begin="BEGIN">Hello Plunker!</h1>
AngularJS 指令 DEMO 中的属性:http://plnkr.co/edit/RxABAHHlxQJSSZz91CYW?p=preview
Attributes in AngularJS directive DEMO: http://plnkr.co/edit/RxABAHHlxQJSSZz91CYW?p=preview
当然,我可以将我的属性名称从 on-drag-start
更改为 on-drag-begin
,但我很好奇.
Of course, I can change my attribute name from on-drag-start
to on-drag-begin
, but I am curious.
我的问题是;
- 为什么我不能使用
on-drag-start
作为属性名称? - 背后的原因是什么?
- 还有,属性名称有什么通用规则吗?
注意:我觉得我的问题格式不正确.欢迎改写.
NOTE: I feel my question is not well formatted. Rewriting is welcomed.
推荐答案
这在 1.2 中被破坏.最好将属性重命名为其他名称并继续.
This was broken in 1.2. It's best to rename the attributes to something else and move on.
这篇关于angularjs 指令无法获取以“-start"结尾的属性;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!