Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix($route): update current route upon service instantiation #5681

Closed
wants to merge 1 commit into from
Closed

fix($route): update current route upon service instantiation #5681

wants to merge 1 commit into from

Conversation

dlukez
Copy link
Contributor

@dlukez dlukez commented Jan 8, 2014

This fixes cases where the first ngView is loaded in a template asynchronously (such as through ngInclude), as the service will miss the first $locationChangeSuccess event otherwise.

Closes #4957

@@ -389,7 +389,7 @@ describe('$route', function() {
var onChangeSpy = jasmine.createSpy('onChange');

$rootScope.$on('$routeChangeStart', onChangeSpy);
expect($route.current).toBeUndefined();
expect($route.current).not.toBeUndefined();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should have an explicit assertion and not not.toBeUndefined()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in checking a specific parameter or just fixing up the silly double negative?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checking specific parameter

@IgorMinar
Copy link
Contributor

can you please fix the assertions? otherwise this looks good to me.

@ghost ghost assigned IgorMinar Jan 8, 2014
@IgorMinar
Copy link
Contributor

I tried to fix the assert but realized that $route.current is in the first test set to some object which doesn't match any of the route definitions.

I also noticed that there is no new test added for this PR. we should add one because we'll regress on this sooner or later.

@IgorMinar
Copy link
Contributor

I'm going to punt on this PR for now and assign it to 1.2.9

@dlukez
Copy link
Contributor Author

dlukez commented Jan 10, 2014

I'll just fix the double negative now. The modified assertions should be enough to imply that $route.current has been set because beforehand it was undefined. In a regression I'd imagine it'd go back to being undefined again.

This fixes cases where the first ngView is loaded in a template asynchronously (such as through ngInclude), as the service will miss the first  event otherwise.

Closes #4957
IgorMinar added a commit that referenced this pull request Jan 13, 2014
This reverts commit 2b344db.

I think I merged this commit prematurely and in addition to that
we found out that it's breaking google apps.

Jen Bourey will provide more info at the original PR #5681
@bourey
Copy link
Contributor

bourey commented Jan 13, 2014

This pull request broke some of our code due to a change in the ordering of the onLocationSuccess event and the route resolve logic. In the past, onLocationSuccess was always fired before the route's resolve method was called. As of this change, onLocationSuccess fired after the resolve method when navigating to a new page (though no change was observed on initial page load).

jamesdaily pushed a commit to jamesdaily/angular.js that referenced this pull request Jan 27, 2014
This reverts commit 2b344db.

I think I merged this commit prematurely and in addition to that
we found out that it's breaking google apps.

Jen Bourey will provide more info at the original PR angular#5681
jamesdaily pushed a commit to jamesdaily/angular.js that referenced this pull request Jan 27, 2014
This reverts commit 2b344db.

I think I merged this commit prematurely and in addition to that
we found out that it's breaking google apps.

Jen Bourey will provide more info at the original PR angular#5681
@tbosch tbosch modified the milestones: 1.2.12, 1.2.11, 1.2.13 Feb 3, 2014
@dlukez
Copy link
Contributor Author

dlukez commented Feb 11, 2014

Apologies for the delayed response, I've been super busy lately.

I spent an hour or two trying to recreate the issue you are describing in plunker and haven't had good results! Could someone give me some guidance on exactly what's going wrong and maybe an example route setup? That would be really helpful. I'm looking to get this PR fixed up in the next week!

@btford btford modified the milestones: 1.2.14, 1.2.13 Feb 15, 2014
@IgorMinar IgorMinar modified the milestones: 1.3.0-beta.1, 1.2.14 Mar 1, 2014
@btford btford modified the milestones: 1.3.0-beta.2, 1.3.0-beta.1 Mar 10, 2014
@tbosch tbosch modified the milestones: 1.3.0-beta.3, 1.3.0-beta.2 Mar 14, 2014
@btford btford modified the milestones: 1.3.0-beta.4, 1.3.0-beta.3 Mar 24, 2014
@petebacondarwin
Copy link
Contributor

Since this original fix breaks other things, we have a new router in the works, and it appears that there is a workaround for this issue at #4957 (comment), I am going to close this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ngView nested inside ngInclude
8 participants