apply() is used to execute an expression in angular from outside of the angular framework.
apply() is used to execute an expression in angular from outside of the angular framework. (For example from browser DOM events, setTimeout, XHR or third party libraries). Because we are calling into the angular framework we need to perform proper scope life cycle of exception handling, executing watches.
An angular expression to be executed.
The result of evaluating the expression.
Schedule the invocation of $apply to occur at a later time.
Schedule the invocation of $apply to occur at a later time. The actual time difference varies across browsers, but is typically around ~10 milliseconds.
This can be used to queue up multiple expressions which need to be evaluated in the same digest.
An angular expression to be executed.
Dispatches an event name downwards to all child scopes (and their children) notifying the registered $rootScope.Scope listeners.
Dispatches an event name downwards to all child scopes (and their children) notifying the registered $rootScope.Scope listeners.
The event life cycle starts at the scope on which $broadcast was called. All listeners listening for name event on this scope get notified. 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.
Any exception emitted from the listeners will be passed onto the $exceptionHandler service.
Event name to broadcast.
Optional one or more arguments which will be passed onto the event listeners.
Removes the current scope (and all of its children) from the parent scope.
Removes the current scope (and all of its children) from the parent scope. Removal implies that calls to $digest() will no longer propagate to the current scope and its children. Removal also implies that the current scope is eligible for garbage collection.
The $destroy() is usually used by directives such as ngRepeat for managing the unrolling of the loop.
Just before a scope is destroyed, a $destroy event is broadcasted on this scope. Application code can register a $destroy event handler that will give it a chance to perform any necessary cleanup.
Note that, in AngularJS, there is also a $destroy jQuery event, which can be used to clean up DOM bindings before an element is removed from the DOM.
Processes all of the watchers of the current scope and its children.
Processes all of the watchers of the current scope and its children. Because a watcher's listener can change the model, the $digest() keeps calling the watchers until no more listeners are firing. This means that it is possible to get into an infinite loop. This function will throw 'Maximum iteration limit exceeded.' if the number of iterations exceeds 10.
Dispatches an event name upwards through the scope hierarchy notifying the registered $rootScope.Scope listeners.
Dispatches an event name upwards through the scope hierarchy notifying the registered $rootScope.Scope listeners.
The event life cycle starts at the scope on which $emit was called. All listeners listening for name event on this scope get notified. Afterwards, the event traverses upwards toward the root scope and calls all registered listeners along the way. The event will stop propagating if one of the listeners cancels it.
Any exception emitted from the listeners will be passed onto the $exceptionHandler service.
Event name to emit.
Optional one or more arguments which will be passed onto the event listeners.
Executes the expression on the current scope and returns the result.
Executes the expression on the current scope and returns the result. Any exceptions in the expression are propagated (uncaught). This is useful when evaluating Angular expressions.
An angular expression to be executed.
Local variables object, useful for overriding values in scope.
The result of evaluating the expression.
Executes the expression on the current scope at a later point in time.
Executes the expression on the current scope at a later point in time. The $evalAsync makes no guarantees as to when the expression will be executed, only that:
An angular expression to be executed.
Local variables object, useful for overriding values in scope.
Returns the unique scope ID (monotonically increasing) useful for debugging.
Returns the unique scope ID (monotonically increasing) useful for debugging.
Unique scope ID (monotonically increasing) useful for debugging.
Creates a new child scope.
Creates a new child scope. The parent scope will propagate the $digest() event. The scope can be removed from the scope hierarchy using $destroy(). $destroy() must be called on a scope when it is desired for the scope and its child scopes to be permanently detached from the parent and thus stop participating in model change detection and listener notification by invoking.
If true, then the scope does not prototypically inherit from the parent scope. The scope is isolated, as it can not see parent scope properties. When creating widgets, it is useful for the widget to not accidentally read parent state.
The Scope that will be the $parent of the newly created scope. Defaults to this scope if not provided. This is used when creating a transclude scope to correctly place it in the scope hierarchy while maintaining the correct prototypical inheritance.
The newly created child scope.
Listens on events of a given type.
Listens on events of a given type. See $emit for discussion of event life cycle. The event listener function format is: function(event, args...). The event object passed into the listener has the following attributes:
Event name to listen on.
Function to call when the event is emitted.
Returns a deregistration function for this listener.
Returns the reference to the parent scope.
Returns the reference to the parent scope.
Reference to the parent scope.
Returns the reference to the root scope.
Returns the reference to the root scope.
Reference to the root scope.
Registers a listener callback to be executed whenever the watchExpression changes.
Registers a listener callback to be executed whenever the watchExpression changes.
The watchExpression is called on every call to $digest() and should return the value that will be watched. (Since $digest() reruns when it detects changes the watchExpression can execute multiple times per $digest() and should be idempotent.)
The listener is called only when the value from the current watchExpression and the previous call to watchExpression are not equal (with the exception of the initial run, see below). Inequality is determined according to reference inequality, strict comparison via the !== Javascript operator, unless objectEquality == true (see next point)
When objectEquality == true, inequality of the watchExpression is determined according to the angular.equals function. To save the value of the object for later comparison, the angular.copy function is used. This therefore means that watching complex objects will have adverse memory and performance implications.
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).
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 listener callback is fired.
The obj 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.
The listener is called whenever anything within the obj has changed. Examples include adding, removing, and moving items belonging to an object or array.
Returns a de-registration function for this listener. When the de-registration function is executed, the internal watch operation is terminated.
A variant of $watch() where it watches an array of watchExpressions.
A variant of $watch() where it watches an array of watchExpressions. If any one expression in the collection changes the listener is executed.
The items in the watchExpressions array are observed via standard $watch operation and are examined on every call to $digest() to see if any items changes.
The listener is called whenever any expression in the watchExpressions array changes.
Returns a de-registration function for all listeners.
Represents an AngularJS Scope
https://docs.angularjs.org/api/ng/type/$rootScope.Scope