Skip to content

Commit defc0e6

Browse files
committed
Update docs
1 parent 9701e9f commit defc0e6

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

docs/content/docs/directive/el.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: ng-el
3+
description: >
4+
Reference to an element
5+
---
6+
7+
### Description
8+
9+
The `ng-el` directive allows you to store a reference to a DOM element in the
10+
current `scope`, making it accessible elsewhere in your template or from your
11+
controller. The reference is automatically removed if the element is removed
12+
from the DOM.
13+
14+
### Parameters
15+
16+
---
17+
18+
#### `ng-el`
19+
20+
- **Type:** `string` (optional)
21+
- **Description:** Name of the key under which the element will be stored in
22+
`scope`. If omitted, the element’s `id` attribute will be used.
23+
- **Example:**
24+
25+
```html
26+
<div id="box" ng-el="$box"></div>
27+
```
28+
29+
---
30+
31+
### Demo
32+
33+
{{< showhtml src="examples/ng-el/ng-el.html" >}}
34+
{{< showraw src="examples/ng-el/ng-el.html" >}}
35+
36+
---
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<section ng-app>
2+
<div ng-el="$item"></div>
3+
<div ng-el id="description"></div>
4+
<button
5+
class="btn"
6+
ng-click="$item.innerHTML = '🐱'; description.innerHTML='The cat has been inserted'"
7+
>
8+
Insert a cat
9+
</button>
10+
</section>

0 commit comments

Comments
 (0)