File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 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+ ---
Original file line number Diff line number Diff line change 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 >
You can’t perform that action at this time.
0 commit comments