Update to Angular 1.1.4
This commit is contained in:
parent
72a485d6e8
commit
f5fc1369ad
585 changed files with 48055 additions and 3041 deletions
106
lib/angular/docs/partials/api/ng.$rootScope.Scope.html
Normal file → Executable file
106
lib/angular/docs/partials/api/ng.$rootScope.Scope.html
Normal file → Executable file
|
@ -2,7 +2,7 @@
|
|||
<span class="hint">(type in module <code ng:non-bindable="">ng</code>
|
||||
)</span>
|
||||
</h1>
|
||||
<div><h2 id="Description">Description</h2>
|
||||
<div><a href="http://github.com/angular/angular.js/edit/master/src/ng/rootScope.js" class="improve-docs btn btn-primary">Improve this doc</a><h2 id="Description">Description</h2>
|
||||
<div class="description"><p>A root scope can be retrieved using the <a href="api/ng.$rootScope"><code>$rootScope</code></a> key from the
|
||||
<a href="api/AUTO.$injector"><code>$injector</code></a>. Child scopes are created using the
|
||||
<a href="api/ng.$rootScope.Scope#$new"><code>$new()</code></a> method. (Most scopes are created automatically when
|
||||
|
@ -10,25 +10,25 @@ compiled HTML template is executed.)</p>
|
|||
|
||||
<p>Here is a simple scope snippet to show how you can interact with the scope.
|
||||
<pre class="prettyprint linenums">
|
||||
angular.injector(['ng']).invoke(function($rootScope) {
|
||||
var scope = $rootScope.$new();
|
||||
scope.salutation = 'Hello';
|
||||
scope.name = 'World';
|
||||
|
||||
expect(scope.greeting).toEqual(undefined);
|
||||
var scope = $rootScope.$new();
|
||||
scope.salutation = 'Hello';
|
||||
scope.name = 'World';
|
||||
|
||||
scope.$watch('name', function() {
|
||||
scope.greeting = scope.salutation + ' ' + scope.name + '!';
|
||||
}); // initialize the watch
|
||||
expect(scope.greeting).toEqual(undefined);
|
||||
|
||||
expect(scope.greeting).toEqual(undefined);
|
||||
scope.name = 'Misko';
|
||||
// still old value, since watches have not been called yet
|
||||
expect(scope.greeting).toEqual(undefined);
|
||||
scope.$watch('name', function() {
|
||||
scope.greeting = scope.salutation + ' ' + scope.name + '!';
|
||||
}); // initialize the watch
|
||||
|
||||
expect(scope.greeting).toEqual(undefined);
|
||||
scope.name = 'Misko';
|
||||
// still old value, since watches have not been called yet
|
||||
expect(scope.greeting).toEqual(undefined);
|
||||
|
||||
scope.$digest(); // fire all the watches
|
||||
expect(scope.greeting).toEqual('Hello Misko!');
|
||||
|
||||
scope.$digest(); // fire all the watches
|
||||
expect(scope.greeting).toEqual('Hello Misko!');
|
||||
});
|
||||
</pre>
|
||||
|
||||
<h3>Inheritance</h3>
|
||||
|
@ -117,7 +117,7 @@ registered <a href="api/ng.$rootScope.Scope#$on"><code>ng.$rootScope.Scope#$on</
|
|||
Afterwards, the event propagates to all direct and indirect scopes of the current scope and
|
||||
calls all registered listeners along the way. The event cannot be canceled.</p>
|
||||
|
||||
<p>Any exception emmited from the <a href="api/ng.$rootScope.Scope#$on"><code>listeners</code></a> will be passed
|
||||
<p>Any exception emitted from the <a href="api/ng.$rootScope.Scope#$on"><code>listeners</code></a> will be passed
|
||||
onto the <a href="api/ng.$exceptionHandler"><code>$exceptionHandler</code></a> service.</p><h4 id="Parameters">Parameters</h4>
|
||||
<ul class="parameters"><li><code ng:non-bindable="">name – {string} – </code>
|
||||
<p>Event name to emit.</p></li>
|
||||
|
@ -279,15 +279,7 @@ state.</p></li>
|
|||
</li>
|
||||
<li><h3 id="$on">$on(name, listener)</h3>
|
||||
<div class="$on"><p>Listens on events of a given type. See <a href="api/ng.$rootScope.Scope#$emit"><code>$emit</code></a> for discussion of
|
||||
event life cycle.</p><h4 id="Parameters">Parameters</h4>
|
||||
<ul class="parameters"><li><code ng:non-bindable="">name – {string} – </code>
|
||||
<p>Event name to listen on.</p></li>
|
||||
<li><code ng:non-bindable="">listener – {function(event)} – </code>
|
||||
<p>Function to call when the event is emitted.</p></li>
|
||||
</ul>
|
||||
<h4 id="Returns">Returns</h4>
|
||||
<div class="returns"><code ng:non-bindable="">{function()}</code>
|
||||
– <p>Returns a deregistration function for this listener.</p>
|
||||
event life cycle.</p>
|
||||
|
||||
<p>The event listener function format is: <code>function(event, args...)</code>. The <code>event</code> object
|
||||
passed into the listener has the following attributes:</p>
|
||||
|
@ -300,7 +292,15 @@ passed into the listener has the following attributes:</p>
|
|||
propagation (available only for events that were <code>$emit</code>-ed).</li>
|
||||
<li><code>preventDefault</code> - <code>{function}</code>: calling <code>preventDefault</code> sets <code>defaultPrevented</code> flag to true.</li>
|
||||
<li><code>defaultPrevented</code> - <code>{boolean}</code>: true if <code>preventDefault</code> was called.</li>
|
||||
</ul></div>
|
||||
</ul><h4 id="Parameters">Parameters</h4>
|
||||
<ul class="parameters"><li><code ng:non-bindable="">name – {string} – </code>
|
||||
<p>Event name to listen on.</p></li>
|
||||
<li><code ng:non-bindable="">listener – {function(event, args...)} – </code>
|
||||
<p>Function to call when the event is emitted.</p></li>
|
||||
</ul>
|
||||
<h4 id="Returns">Returns</h4>
|
||||
<div class="returns"><code ng:non-bindable="">{function()}</code>
|
||||
– <p>Returns a deregistration function for this listener.</p></div>
|
||||
</div>
|
||||
</li>
|
||||
<li><h3 id="$watch">$watch(watchExpression, listener, objectEquality)</h3>
|
||||
|
@ -379,6 +379,58 @@ the <code>watchExpression</code> changes.</p>
|
|||
– <p>Returns a deregistration function for this listener.</p></div>
|
||||
</div>
|
||||
</li>
|
||||
<li><h3 id="$watchCollection">$watchCollection(obj, listener)</h3>
|
||||
<div class="$watchcollection"><p>Shallow watches the properties of an object and fires whenever any of the properties change
|
||||
(for arrays this implies watching the array items, for object maps this implies watching the properties).
|
||||
If a change is detected the <code>listener</code> callback is fired.</p>
|
||||
|
||||
<ul>
|
||||
<li>The <code>obj</code> collection is observed via standard $watch operation and is examined on every call to $digest() to
|
||||
see if any items have been added, removed, or moved.</li>
|
||||
<li>The <code>listener</code> is called whenever anything within the <code>obj</code> has changed. Examples include adding new items
|
||||
into the object or array, removing and moving items around.</li>
|
||||
</ul>
|
||||
|
||||
<h4>Example</h4>
|
||||
|
||||
<pre class="prettyprint linenums">
|
||||
$scope.names = ['igor', 'matias', 'misko', 'james'];
|
||||
$scope.dataCount = 4;
|
||||
|
||||
$scope.$watchCollection('names', function(newNames, oldNames) {
|
||||
$scope.dataCount = newNames.length;
|
||||
});
|
||||
|
||||
expect($scope.dataCount).toEqual(4);
|
||||
$scope.$digest();
|
||||
|
||||
//still at 4 ... no changes
|
||||
expect($scope.dataCount).toEqual(4);
|
||||
|
||||
$scope.names.pop();
|
||||
$scope.$digest();
|
||||
|
||||
//now there's been a change
|
||||
expect($scope.dataCount).toEqual(3);
|
||||
</pre><h4 id="Parameters">Parameters</h4>
|
||||
<ul class="parameters"><li><code ng:non-bindable="">obj – {string|Function(scope)} – </code>
|
||||
<p>Evaluated as <a href="guide/expression">expression</a>. The expression value
|
||||
should evaluate to an object or an array which is observed on each
|
||||
<a href="api/ng.$rootScope.Scope#$digest"><code>$digest</code></a> cycle. Any shallow change within the collection will trigger
|
||||
a call to the <code>listener</code>.</p></li>
|
||||
<li><code ng:non-bindable="">listener – {function(newCollection, oldCollection, scope)} – </code>
|
||||
<p>a callback function that is fired with both
|
||||
the <code>newCollection</code> and <code>oldCollection</code> as parameters.
|
||||
The <code>newCollection</code> object is the newly modified data obtained from the <code>obj</code> expression and the
|
||||
<code>oldCollection</code> object is a copy of the former collection data.
|
||||
The <code>scope</code> refers to the current scope.</p></li>
|
||||
</ul>
|
||||
<h4 id="Returns">Returns</h4>
|
||||
<div class="returns"><code ng:non-bindable="">{function()}</code>
|
||||
– <p>Returns a de-registration function for this listener. When the de-registration function is executed
|
||||
then the internal watch operation is terminated.</p></div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="member property"><h2 id="Properties">Properties</h2>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue