trait Scope extends Object
Represents an AngularJS Scope
- Annotations
- @RawJSType() @native()
- See also
- Alphabetic
- By Inheritance
- Scope
- Object
- Any
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
def
$apply(exp: Any = js.native): Any
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.
- exp
An angular expression to be executed.
- string: execute using the rules as defined in expression.
- function(scope): execute the function with current scope parameter.
- returns
The result of evaluating the expression.
-
def
$applyAsync(exp: Any = js.native): Any
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.
- exp
An angular expression to be executed.
- string: execute using the rules as defined in expression.
- function(scope): execute the function with current scope parameter.
-
def
$broadcast(name: String, args: Any*): Object
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.
- name
Event name to broadcast.
- args
Optional one or more arguments which will be passed onto the event listeners.
-
def
$destroy(): Unit
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.
-
def
$digest(): Unit
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.
-
def
$emit(name: String, args: Any*): Object
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.
- name
Event name to emit.
- args
Optional one or more arguments which will be passed onto the event listeners.
-
def
$eval[T](expression: Any = js.native, locals: Object = js.native): T
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.
- expression
An angular expression to be executed.
- string: execute using the rules as defined in expression.
- function(scope): execute the function with the current scope parameter.
- locals
Local variables object, useful for overriding values in scope.
- returns
The result of evaluating the expression.
-
def
$evalAsync(expression: Any = js.native, locals: Object = js.native): Unit
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:
- it will execute after the function that scheduled the evaluation (preferably before DOM rendering).
- at least one $digest cycle will be performed after expression execution.
- expression
An angular expression to be executed.
- locals
Local variables object, useful for overriding values in scope.
-
def
$id: Int
Returns the unique scope ID (monotonically increasing) useful for debugging.
Returns the unique scope ID (monotonically increasing) useful for debugging.
- returns
Unique scope ID (monotonically increasing) useful for debugging.
-
def
$new(isolate: Boolean, parent: Scope = js.native): Scope
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.
- isolate
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.
- parent
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.
- returns
The newly created child scope.
-
def
$on(name: String, listener: Function): Function
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:
- name
Event name to listen on.
- listener
Function to call when the event is emitted.
- returns
Returns a deregistration function for this listener.
-
def
$parent: Scope
Returns the reference to the parent scope.
Returns the reference to the parent scope.
- returns
Reference to the parent scope.
-
def
$root: Scope
Returns the reference to the root scope.
Returns the reference to the root scope.
- returns
Reference to the root scope.
-
def
$watch(watchExpression: Any, listener: Function = js.native, objectEquality: Boolean = js.native): Function
Registers a listener callback to be executed whenever the watchExpression changes.
Registers a listener callback to be executed whenever the watchExpression changes.
- watchExpression
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.)
- listener
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)
- objectEquality
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.
-
def
$watchCollection(obj: Any, listener: Function): Function
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.
- obj
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.
- listener
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
Returns a de-registration function for this listener. When the de-registration function is executed, the internal watch operation is terminated.
-
def
$watchGroup(watchExpressions: Array[Any], listener: Function): Function
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.
- watchExpressions
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.
- listener
The listener is called whenever any expression in the watchExpressions array changes.
- returns
Returns a de-registration function for all listeners.
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hasOwnProperty(v: String): Boolean
- Definition Classes
- Object
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isPrototypeOf(v: Object): Boolean
- Definition Classes
- Object
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
propertyIsEnumerable(v: String): Boolean
- Definition Classes
- Object
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toLocaleString(): String
- Definition Classes
- Object
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
valueOf(): Any
- Definition Classes
- Object
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )