Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
932 views
in Technique[技术] by (71.8m points)

angularjs directive cannot get attributes ending with "-start"

I wanted to use on-drag-start as an attribute in AngularJS directive, called ngDraggable.
However, it seems not possible to have that attribute.

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>

Attributes in pure javasctipt DEMO: http://plnkr.co/edit/6iODSnf56KtwPFpoC7ck?p=preview

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>

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.

My questions are;

  1. why I cannot use on-drag-start as an attribute name?
  2. what's the reason behind it?
  3. and, is there any general rule for attribute names?

NOTE: I feel my question is not well formatted. Rewriting is welcomed.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This was broken in 1.2. It's best to rename the attributes to something else and move on.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...