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

Commit 3e6172e

Browse files
committed
update docs and fix codestyle
1 parent 70433f8 commit 3e6172e

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

src/ng/directive/ngRef.js

+24-30
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@
1010
* to the given property in the current scope. If no controller exists, the jqlite-wrapped DOM
1111
* element will be added to the scope.
1212
*
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.
1414
*
1515
*
1616
* @element ANY
1717
* @param {string} ngRef property name - A valid AngularJS expression identifier to which the
1818
* 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).
2123
*
2224
*
2325
* @example
@@ -33,17 +35,13 @@
3335
* </div>
3436
* </file>
3537
* <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+
* }
4745
* });
4846
* </file>
4947
* <file name="protractor.js" type="protractor">
@@ -58,7 +56,7 @@
5856
*
5957
* @example
6058
* ### ngRef inside scopes
61-
* This example shows how new scopes limits
59+
* This example shows how scopes contain `ngRef` assignments.
6260
* <example name="ng-ref-scopes" module="myApp">
6361
* <file name="index.html">
6462
* <h3>Outer Toggle</h3>
@@ -73,30 +71,26 @@
7371
* <div>outerToggle.isOpen(): {{outerToggle.isOpen() | json}}</div>
7472
* </li>
7573
* </ul>
76-
* <div>ngRepeat.isOpen(): {{ngRepeatToggle.isOpen() | json}}</div>
74+
* <div>ngRepeatToggle.isOpen(): {{ngRepeatToggle.isOpen() | json}}</div>
7775
*
7876
* <h3>ngIf toggle</h3>
7977
* <div ng-if="true">
8078
* <my-toggle ng-ref="ngIfToggle">ngIf Toggle</my-toggle>
8179
* <div>ngIfToggle.isOpen(): {{ngIfToggle.isOpen() | json}}</div>
8280
* <div>outerToggle.isOpen(): {{outerToggle.isOpen() | json}}</div>
8381
* </div>
84-
* <div>ngIf.isOpen(): {{ngIf.isOpen() | json}}</div>
82+
* <div>ngIfToggle.isOpen(): {{ngIfToggle.isOpen() | json}}</div>
8583
* </file>
8684
* <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', {
9787
* template: '<button ng-click="$ctrl.toggle()" ng-transclude></button>',
9888
* 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+
* }
10094
* });
10195
* </file>
10296
* <file name="protractor.js" type="protractor">
@@ -184,7 +178,7 @@
184178

185179
var ngRefMinErr = minErr('ngRef');
186180

187-
var ngRefDirective = ['$parse',function($parse) {
181+
var ngRefDirective = ['$parse', function($parse) {
188182
return {
189183
priority: -1,
190184
restrict: 'A',
@@ -230,7 +224,7 @@ var ngRefDirective = ['$parse',function($parse) {
230224
// only remove it if value has not changed,
231225
// carefully because animations (and other procedures) may duplicate elements
232226
if (getter(scope) === refValue) {
233-
setter(scope, null);
227+
setter(scope, null);
234228
}
235229
});
236230
};

0 commit comments

Comments
 (0)