-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Hi there:
I'm successfully using UI-Router on a very large production project and currently using Angular v1.2.0-rc.2; things are currently stable and I have not run into any issues since we're not using any animations right now. UI-Router has been a lifesaver since Angular's ng-view was far too limiting for what we needed to be able to do with our UI; thanks a lot for all your hard work! 😄
The issue that I've run into actually has to do with a separate project. Our company also has a home-grown system for tracking usage data and providing analytics for how our products are actually being used. Now that our app (which is also our first product using Angular) is getting ready to be released into the wild, I've been working on the tracking script that will collect the usage data based on our predefined metrics.
To provide a little bit of background information: the relevant part of this tracking system consists of 2 parts, the base library and the app-specific tracking script. Both are written in jQuery, since the same tracking system is also used to track other, older apps which are not using Angular or any other front-end framework. In a nutshell, the tracking works primarily by just attaching delegated event handlers such as $(document).on('click', '#someID a.someClass', extractorFunction(event) { ... });
where the extractor function grabs some other data (eg. the element's ID, or a regex of the element's HREF attribute, or perhaps one of its ancestors' IDs in order to record some sort of contextual data) and then ultimately sends that extracted information to another server. The system is stable and working well for all our other apps.
Now, after going through and writing the tracking script for our Angular app (which I have a lot of experience in now, having done it for all our other apps) I noticed that only about 50% of the specified trackers in this script were working properly. Of the others, they were either not tracking at all (that is, their event handlers were just not being fired), or their extractor functions were not extracting the proper data.
After hours of debugging, I finally figured out that the problem is that even though the DOM tree appears fine, relationships appear to be broken whenever the ui-view
directive is used. For example, an element inside of one ui-view
might properly fire its event handler (extractor function), but if that extractor function relies on $(element).parents()
to get some contextual data, that function only returns the DOM tree up to, but not including, the element with the ui-view
directive attached. In another case, a tracker such as $(document).on('click', '#someID a.someClass', extractorFunction(event) { ... });
might not fire at all if #someID
is declared in one ui-view
and a.someClass
exists inside a different (nested) ui-view
.
I assume this isn't the desired/intended behavior -- but correct me if I'm wrong. I also don't know if this is related to, and might potentially be resolved by, the larger-scale refactor of ui-view
that I saw is already in progress. I have no idea how this compares to how Angular's own ng-view
functions, as I haven't used it in months and at this point there's no way for us to go back to it.
If this does indeed turn out to be a bug, I realize this might not be a trivial fix, but I just wanted to confirm the issue first before I make any large-scale changes either to our app or to the tracking script.
Thanks, and let me know if you need any more information! I can't really provide any sample code as-is, since both projects are far too huge to port to, say, Plunkr, but if needed, I can try to create a small dummy project tomorrow to illustrate the issue.