Scope
can/view/scope
inherits: can.Construct
Create a lookup node for keys.
new can.view.Scope(context, [parent])
Parameters
-
context
{*}
A value that represents the current context. This is often an object or observable and is the first place
-
parent
{can.view.Scope}
OptionalThe parent scope. If a
key
value is not found in the current scope, it will then look in the parent scope.
Returns
{can.view.Scope}
Returns a scope instance.
Use
A
can.view.Scope
represents a lookup context and parent contexts that can be used to lookup a key value.If no parent scope is provided, only the scope's context will be explored for values. For example:
However, if a
parent
scope is provided, key values will be searched in the parent's contexxt after the initial context is expored. For example:Use add to easily create a new scope from a parent scope like: