Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 6997c1b

Browse files
committed
docs(guide/directive): clarify which type of matching directives support
Closes #15710
1 parent 4a030f3 commit 6997c1b

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

docs/content/guide/directive.ngdoc

+10-4
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,13 @@ The other forms shown above are accepted for legacy reasons but we advise you to
120120

121121
### Directive types
122122

123-
`$compile` can match directives based on element names, attributes, class names, as well as comments.
123+
`$compile` can match directives based on element names (E), attributes (A), class names (C),
124+
and comments (M).
124125

125-
All of the Angular-provided directives match attribute name, tag name, comments, or class name.
126-
The following demonstrates the various ways a directive (`myDir` in this case) can be referenced
127-
from within a template:
126+
The built-in the AngularJS directives show in their documentation page which type of matching they support.
127+
128+
The following demonstrates the various ways a directive that matches all 4 types
129+
(`myDir` in this case) can be referenced from within a template.
128130

129131
```html
130132
<my-dir></my-dir>
@@ -133,6 +135,10 @@ from within a template:
133135
<span class="my-dir: exp;"></span>
134136
```
135137

138+
A directive can specify which of the 4 matching types it supports in the
139+
{@link ng.$compile#-restrict- `restrict`} property of the directive definition object.
140+
The default is `EA`.
141+
136142
<div class="alert alert-success">
137143
**Best Practice:** Prefer using directives via tag name and attributes over comment and class names.
138144
Doing so generally makes it easier to determine what directives a given element matches.

src/ng/directive/ngRepeat.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* @ngdoc directive
77
* @name ngRepeat
88
* @multiElement
9+
* @restrict A
910
*
1011
* @description
1112
* The `ngRepeat` directive instantiates a template once per item from a collection. Each template

0 commit comments

Comments
 (0)