This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(ngRoute): allow ngView
to be included in an asynchronously loaded template
#14088
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ed template During it's linking phase, `ngView` relies on the info provided in `$route.current` for instantiating the initial view. `$route.current` is set in the callback of a listener to `$locationChangeSuccess`, which is registered during the instantiation of the `$route` service. Thus, it is crucial that the `$route` service is instantiated before the initial `$locationChangeSuccess` is fired. Since `ngView` declares `$route` as a dependency, the service is instantiated in time if `ngView` is present during the initial load of the page. Yet, in cases where `ngView` is included in a template that is loaded asynchronously (e.g. in another directive's template), the directive factory might not be called soon enough for `$route` to be instantiated before the initial `$locationChangeSuccess` event is fired. This commit fixes it, by always instantiating `$route` up front, during the initialization phase. Fixes angular#1213 Fixes angular#6812
2a639e6
to
3f8b285
Compare
Would be cool to get this fixed! Does this commit address the problems the first fix for this had? Namely that this caused lots of test failures in a google app because the order of some events changed? |
@Narretz, I'm not aware of the first fix you mention, but I'm quite confident, there won't be any issues with event order. This fix doesn't change the order of any events, it just ensures |
I found this comment: #1213 (comment) |
Ah, right, I forgot about that. No, this fix just ensures |
Ok, then it LGTM. |
gkalpak
added a commit
that referenced
this pull request
Feb 25, 2016
…ed template During it's linking phase, `ngView` relies on the info provided in `$route.current` for instantiating the initial view. `$route.current` is set in the callback of a listener to `$locationChangeSuccess`, which is registered during the instantiation of the `$route` service. Thus, it is crucial that the `$route` service is instantiated before the initial `$locationChangeSuccess` is fired. Since `ngView` declares `$route` as a dependency, the service is instantiated in time if `ngView` is present during the initial load of the page. Yet, in cases where `ngView` is included in a template that is loaded asynchronously (e.g. in another directive's template), the directive factory might not be called soon enough for `$route` to be instantiated before the initial `$locationChangeSuccess` event is fired. This commit fixes it, by always instantiating `$route` up front, during the initialization phase. Fixes #1213 Fixes #6812 Closes #14088
gkalpak
added a commit
that referenced
this pull request
Feb 25, 2016
…ed template During it's linking phase, `ngView` relies on the info provided in `$route.current` for instantiating the initial view. `$route.current` is set in the callback of a listener to `$locationChangeSuccess`, which is registered during the instantiation of the `$route` service. Thus, it is crucial that the `$route` service is instantiated before the initial `$locationChangeSuccess` is fired. Since `ngView` declares `$route` as a dependency, the service is instantiated in time if `ngView` is present during the initial load of the page. Yet, in cases where `ngView` is included in a template that is loaded asynchronously (e.g. in another directive's template), the directive factory might not be called soon enough for `$route` to be instantiated before the initial `$locationChangeSuccess` event is fired. This commit fixes it, by always instantiating `$route` up front, during the initialization phase. Fixes #1213 Fixes #6812 Closes #14088
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
During it's linking phase,
ngView
relies on the info provided in$route.current
for instantiating the initial view.$route.current
is set in the callback of a listener to$locationChangeSuccess
, which is registered during the instantiation of the$route
service.Thus, it is crucial that the
$route
service is instantiated before the initial$locationChangeSuccess
is fired. SincengView
declares$route
as a dependency, the service is instantiated in time ifngView
is present during the initial load of the page.Yet, in cases where
ngView
is included in a template that is loaded asynchronously (e.g. in another directive's template), the directive factory might not be called soon enough for$route
to be instantiated before the initial$locationChangeSuccess
event is fired.This commit fixes it, by always instantiating
$route
up front, during the initialization phase.Fixes #1213
Fixes #6812