Registers a ui-view
component
When a ui-view
component is created, it uses this method to register itself.
After registration the [[sync]] method is used to ensure all ui-view
are configured with the proper [[ViewConfig]].
Note: the ui-view
component uses the ViewConfig
to determine what view should be loaded inside the ui-view
,
and what the view's state context is.
Note: There is no corresponding deregisterUIView
.
A ui-view
should hang on to the return value of registerUIView
and invoke it to deregister itself.
The metadata for a UIView
a de-registration function used when the view is destroyed.
Static
matchesInternal
Given a ui-view and a ViewConfig, determines if they "match".
A ui-view has a fully qualified name (fqn) and a context object. The fqn is built from its overall location in the DOM, describing its nesting relationship to any parent ui-view tags it is nested inside of.
A ViewConfig has a target ui-view name and a context anchor. The ui-view name can be a simple name, or can be a segmented ui-view path, describing a portion of a ui-view fqn.
In order for a ui-view to match ViewConfig, ui-view's $type must match the ViewConfig's $type
If the ViewConfig's target ui-view name is a simple name (no dots), then a ui-view matches if:
If the ViewConfig's target ui-view name is a segmented name (with dots), then a ui-view matches if:
Example:
DOM:
ngViews: [ { fqn: "$default", creationContext: { name: "" } }, { fqn: "$default.foo", creationContext: { name: "A" } }, { fqn: "$default.foo.$default", creationContext: { name: "A.B" } } { fqn: "$default.foo.$default.bar", creationContext: { name: "A.B.C" } } ]
These four view configs all match the ui-view with the fqn: "$default.foo.$default.bar":
Using ViewConfig3 as an example, it matches the ui-view with fqn "$default.foo.$default.bar" because:
The View service
This service pairs existing
ui-view
components (which live in the DOM) with view configs (from the state declaration objects: [[StateDeclaration.views]]).After a successful Transition, the views from the newly entered states are activated via [[activateViewConfig]]. The views from exited states are deactivated via [[deactivateViewConfig]]. (See: the [[registerActivateViews]] Transition Hook)
As
ui-view
components pop in and out of existence, they register themselves using [[registerUIView]].When the [[sync]] function is called, the registered
ui-view
(s) ([[ActiveUIView]]) are configured with the matching [ViewConfig]