Options
Menu

Class ViewService

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) ([[UIViewConfig]] are configured with the matching ViewConfig(s) ([[ActiveUIView]]).

Hierarchy

  • ViewService

Index

Constructors

Properties

_rootContext: ViewContext
_uiViews: ActiveUIView[] = []
_viewConfigFactories: object

Type declaration

_viewConfigs: ViewConfig[] = []

Methods

  • activateViewConfig(viewConfig: ViewConfig): void
  • active(): Array<any>
  • Returns the list of views on the page containing loaded content.

  • Returns the list of views on the page containing loaded content.

    Returns Array<any>

    :

    Returns an array of fully-qualified view names.


  • available(): Array<any>
  • Returns the list of views currently available on the page, by fully-qualified name.

  • Returns the list of views currently available on the page, by fully-qualified name.

    Returns Array<any>

    :

    Returns an array of fully-qualified view names.


  • deactivateViewConfig(viewConfig: ViewConfig): void
  • Deactivates a ViewConfig.

  • Deactivates a ViewConfig.

    This function deactivates a ViewConfig. After calling sync, it will un-pair from any ui-view with which it is currently paired.

    Parameters

    • viewConfig ViewConfig
      :

      The ViewConfig view to deregister.

    Returns void


  • registerUIView(uiView: ActiveUIView): (Anonymous function)
  • Registers a ui-view component

  • 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.

    Parameters

    • uiView ActiveUIView
      :

      The metadata for a UIView

    Returns (Anonymous function)

    :

    a de-registration function used when the view is destroyed.


  • sync(): void
  • normalizeUIViewTarget(context: ViewContext, rawViewName?: string): object
  • Normalizes a view's name from a state.views configuration block.

  • Normalizes a view's name from a state.views configuration block.

    Parameters

    • context ViewContext
      :

      the context object (state declaration) that the view belongs to

    • rawViewName: Default value  string = ""
      :

      the name of the view, as declared in the StateDeclaration.views

    Returns object

    :

    the normalized uiViewName and uiViewContextAnchor that the view targets

    • uiViewContextAnchor: string
    • uiViewName: string

Object literals

_pluginapi: object
_rootViewContext: any = this._rootViewContext.bind(this)
_viewConfigFactory: any = this._viewConfigFactory.bind(this)
  • _registeredUIViews(): Array<ActiveUIView>

Generated using TypeDoc