angularjs指令不能获取属性与&QUOT结束; -start" [英] angularjs directive cannot get attributes ending with "-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.
以下code为纯JavaScript,我可以得到上拖动启动
作为一个属性。
我想我可以得到任何属性,无论属性名的。
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 DEMO:<一href=\"http://plnkr.co/edit/6iODSnf56KtwPFpoC7ck?p=$p$pview\">http://plnkr.co/edit/6iODSnf56KtwPFpoC7ck?p=$p$pview
然而,在AngularjS以下code,我不能让 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:<一href=\"http://plnkr.co/edit/RxABAHHlxQJSSZz91CYW?p=$p$pview\">http://plnkr.co/edit/RxABAHHlxQJSSZz91CYW?p=$p$pview
Attributes in AngularJS directive DEMO: http://plnkr.co/edit/RxABAHHlxQJSSZz91CYW?p=preview
当然,我可以从上拖动启动
改变我的属性名称上拖放开始
,但我很好奇。
Of course, I can change my attribute name from on-drag-start
to on-drag-begin
, but I am curious.
我的问题是;
- 为什么我不能使用
上拖动启动
作为一个属性的名字吗? - 什么是它背后的原因是什么?
- 和,是有属性名的一般规则?
- why I cannot use
on-drag-start
as an attribute name? - what's the reason behind it?
- and, is there any general rule for attribute names?
请注意:我觉得我的问题是格式不正确。重写欢迎。
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指令不能获取属性与&QUOT结束; -start&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!