Closed falsyvalues closed 6 years ago
Here's what I recommend:
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
)angular.element().data('$uiView')
data.Plunker example: http://plnkr.co/edit/vPSZL8X78v8IUh4acorv?p=preview
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
:tada:.
Looking forward for onSync
release.
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
[x] 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
[x] I have already reviewed the sample application for examples of common approaches
[x] I believe my question can only be answered by the UI-Router maintainers
Described in Feature Request.