Skip to content

API to access to mounting element for state (uiView element in html) #3573

Closed
@falsyvalues

Description

@falsyvalues

This is a:

  • Bug Report
  • Feature Request
  • General Query

My version of UI-Router is: 1.0.11 ng1

Feature Request

Would be nice to have an access to list of mounting elements (uiViews) corresponding to state, possibly through existing views() API.

Code below is an example what can be achieved right now but contains some downsides (but illustrate the idea behind this):

  • Search is done through all document (its not state context aware like views())
  • Search is done on every invoke
  • Supports only one view (How to query for a proper element using views() data?)
$transitionsProvider.onStart({
    from: 'a.*',
    to: 'a.*'
}, (transition) => {
    const fromState = transition.from();

    if (typeof fromState.template === 'string') {
        // Returns as an exmaple "my-directive" it will looks different with components case
        const elementName = getElementNameFromTemplate(fromState.template);
       // There is no way to find proper uiView element as a root
        const elementInsideSomeUiView = angular.element(document).find(elementName);
        // Do anything with element
    }
});

General Query

Described in Feature Request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions