You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)=>{constfromState=transition.from();if(typeoffromState.template==='string'){// Returns as an exmaple "my-directive" it will looks different with components caseconstelementName=getElementNameFromTemplate(fromState.template);// There is no way to find proper uiView element as a rootconstelementInsideSomeUiView=angular.element(document).find(elementName);// Do anything with element}});
Create a ui-view directive and track when the directive is created and destroyed. Keep a reference to the directive's element. (the directive will share the same element as ui-router's ui-view)
Register a transition hook which checks all the elements' angular.element().data('$uiView') data.
I've also added an onSync callback to the view plugin API. I will release the new onSync api in a future release of ui-router. Plugin APIs are lower level than the rest of ui-router APIs and is more likely to change in the future. The onSync API will informs listeners of each $view.sync() event and provides the list of all active ui-view and the matching view configs (from state views block). This API may never provide an actual element as part of the api because it does not always make sense in all frameworks and environments (such as server-side rendering)
Hi @christopherthielen thanks for looking into it.
I guess example could be extended with some injectable registry of ui-views (managed via directive) which could be useful with onSync 🎉.
Looking forward for onSync release.
wawyed
pushed a commit
to wawyed/core
that referenced
this issue
Mar 3, 2018
This is a:
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):
views()
)views()
data?)General Query
I have already asked my question on StackOverflow and nobody could answer the question
Found this one: https://stackoverflow.com/questions/28234260/how-can-i-get-a-reference-to-the-target-element-with-ui-view-attribute-in-ui-rou
I have already reviewed the sample application for examples of common approaches
I believe my question can only be answered by the UI-Router maintainers
Described in Feature Request.
The text was updated successfully, but these errors were encountered: