|
10 | 10 | * to the given property in the current scope. If no controller exists, the jqlite-wrapped DOM
|
11 | 11 | * element will be added to the scope.
|
12 | 12 | *
|
13 |
| - * If the element with ngRef is destroyed `null` is assigned to the property. |
| 13 | + * If the element with `ngRef` is destroyed `null` is assigned to the property. |
14 | 14 | *
|
15 | 15 | *
|
16 | 16 | * @element ANY
|
17 | 17 | * @param {string} ngRef property name - A valid AngularJS expression identifier to which the
|
18 | 18 | * controller or jqlite-wrapped DOM element will be bound.
|
19 |
| - * @param {string=} ngRefElement void - If specified, ngRef will always bind the jqlite-wrapped |
20 |
| - * DOM-element even if a controller is available. |
| 19 | + * @param {string=} ngRefRead read value - The name of a directive (or component) on this element, |
| 20 | + * or the special string `$element`. If a name is provided, `ngRef` will |
| 21 | + * assign the matching controller. If `$element` is provided, the element |
| 22 | + * itself is assigned (even if a controller is available). |
21 | 23 | *
|
22 | 24 | *
|
23 | 25 | * @example
|
|
33 | 35 | * </div>
|
34 | 36 | * </file>
|
35 | 37 | * <file name="index.js">
|
36 |
| - * angular.module('myApp', []); |
37 |
| - * </file> |
38 |
| - * <file name="toggle.js"> |
39 |
| - * function ToggleController() { |
40 |
| - * var opened = false; |
41 |
| - * this.isOpen = function() { return opened; }; |
42 |
| - * this.toggle = function() { opened = !opened; }; |
43 |
| - * } |
44 |
| - * |
45 |
| - * angular.module('myApp').component('myToggle', { |
46 |
| - * controller: ToggleController |
| 38 | + * angular.module('myApp', []) |
| 39 | + * .component('myToggle', { |
| 40 | + * controller: function ToggleController() { |
| 41 | + * var opened = false; |
| 42 | + * this.isOpen = function() { return opened; }; |
| 43 | + * this.toggle = function() { opened = !opened; }; |
| 44 | + * } |
47 | 45 | * });
|
48 | 46 | * </file>
|
49 | 47 | * <file name="protractor.js" type="protractor">
|
|
58 | 56 | *
|
59 | 57 | * @example
|
60 | 58 | * ### ngRef inside scopes
|
61 |
| - * This example shows how new scopes limits |
| 59 | + * This example shows how scopes contain `ngRef` assignments. |
62 | 60 | * <example name="ng-ref-scopes" module="myApp">
|
63 | 61 | * <file name="index.html">
|
64 | 62 | * <h3>Outer Toggle</h3>
|
|
73 | 71 | * <div>outerToggle.isOpen(): {{outerToggle.isOpen() | json}}</div>
|
74 | 72 | * </li>
|
75 | 73 | * </ul>
|
76 |
| - * <div>ngRepeat.isOpen(): {{ngRepeatToggle.isOpen() | json}}</div> |
| 74 | + * <div>ngRepeatToggle.isOpen(): {{ngRepeatToggle.isOpen() | json}}</div> |
77 | 75 | *
|
78 | 76 | * <h3>ngIf toggle</h3>
|
79 | 77 | * <div ng-if="true">
|
80 | 78 | * <my-toggle ng-ref="ngIfToggle">ngIf Toggle</my-toggle>
|
81 | 79 | * <div>ngIfToggle.isOpen(): {{ngIfToggle.isOpen() | json}}</div>
|
82 | 80 | * <div>outerToggle.isOpen(): {{outerToggle.isOpen() | json}}</div>
|
83 | 81 | * </div>
|
84 |
| - * <div>ngIf.isOpen(): {{ngIf.isOpen() | json}}</div> |
| 82 | + * <div>ngIfToggle.isOpen(): {{ngIfToggle.isOpen() | json}}</div> |
85 | 83 | * </file>
|
86 | 84 | * <file name="index.js">
|
87 |
| - * angular.module('myApp', []); |
88 |
| - * </file> |
89 |
| - * <file name="toggle.js"> |
90 |
| - * function ToggleController() { |
91 |
| - * var opened = false; |
92 |
| - * this.isOpen = function() { return opened; }; |
93 |
| - * this.toggle = function() { opened = !opened; }; |
94 |
| - * } |
95 |
| - * |
96 |
| - * angular.module('myApp').component('myToggle', { |
| 85 | + * angular.module('myApp', []) |
| 86 | + * .component('myToggle', { |
97 | 87 | * template: '<button ng-click="$ctrl.toggle()" ng-transclude></button>',
|
98 | 88 | * transclude: true,
|
99 |
| - * controller: ToggleController |
| 89 | + * controller: function ToggleController() { |
| 90 | + * var opened = false; |
| 91 | + * this.isOpen = function() { return opened; }; |
| 92 | + * this.toggle = function() { opened = !opened; }; |
| 93 | + * } |
100 | 94 | * });
|
101 | 95 | * </file>
|
102 | 96 | * <file name="protractor.js" type="protractor">
|
|
184 | 178 |
|
185 | 179 | var ngRefMinErr = minErr('ngRef');
|
186 | 180 |
|
187 |
| -var ngRefDirective = ['$parse',function($parse) { |
| 181 | +var ngRefDirective = ['$parse', function($parse) { |
188 | 182 | return {
|
189 | 183 | priority: -1,
|
190 | 184 | restrict: 'A',
|
@@ -230,7 +224,7 @@ var ngRefDirective = ['$parse',function($parse) {
|
230 | 224 | // only remove it if value has not changed,
|
231 | 225 | // carefully because animations (and other procedures) may duplicate elements
|
232 | 226 | if (getter(scope) === refValue) {
|
233 |
| - setter(scope, null); |
| 227 | + setter(scope, null); |
234 | 228 | }
|
235 | 229 | });
|
236 | 230 | };
|
|
0 commit comments