-
Notifications
You must be signed in to change notification settings - Fork 25.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ComponentRouter] templateUrl and lifecycle hook in Angular 1 #4633
Comments
Here is a Plunker (navigate between Home and Test) : |
@btford any idea ? |
@btford any idea of how long to fix this bug ? |
No On Wed, Oct 28, 2015, 12:03 Vincent Guédé [email protected] wrote:
|
I made other tests : $onDeactivate either doesn't work with templateUrl. |
@vguede fancy sending a PR with (at least) a failing test? Maybe we can sort things out together then :) |
@PascalPrecht I don't have a PR, but if it can helps, there is this Plunker : http://plnkr.co/edit/jLp9Z7DGMl1Dl09dQwF8?p=preview |
@vguede correct! Let's make a PR out of it! :) |
@vguede are you using the npm build or your own built angular_1_router file? |
@brandonroberts I use my own built angular_1_router file. I will try with the npm build. |
I updated my plunkr with the npm build : same bug. |
@vguede I wasn't suggesting you use the npm build. I was gonna suggest a temporary fix, but need to verify it will work |
@brandonroberts if you have a fix, it will help me a lot ! |
@vguede My suggestion is based on you already having your templates loaded using the $templateCache. Basically you wrap the section that checks for the $onActivate in a $timeout. I'm blaming it on the digest cycle and I'm just using a $timeout to force another cycle. The $timeout change starts on line 156 in the angular_1_router.js build. Here is a working plunk that includes the change in the angular 1 router file. |
@brandonroberts It works fine indeed if my templates are already loaded in the $templateCache. Many thanks to this fix ! |
@brandonroberts It isn't the same issue, but have you a fix to implement redirect in $canActivate hook (see #2965) ? |
@vguede You can use DI with the $canActivate hook. I updated the plunk example with an admin route. |
@brandonroberts I forked your plunkr using promises in $canActivate (http://plnkr.co/edit/UfDNQIEMIGK9LNzmFhG3?p=preview). Do you know why it doesn't work ? |
@vguede You should always return a boolean, whether it be a true/false or a promise that resolves true/false. Don't reject in the lifecycle hooks. So just change your |
@brandonroberts It works fine ! Many thanks again ;o) |
👍 |
How about we piggy back on top of the component's |
Nope that doesn't work because we still need to be told when the component is being instantiated. |
Another possibility is to hook into the same API that Protractor uses to know when all XHR requests have settled (i.e. completed)... |
One more possibility is, somehow, to expose the templateUrl request promise on the link function that is returned so that we can hook into doing work when the full async compilation has completed... |
Hi @petebacondarwin, Do we have the fix for this issue in angular router 1 yet? cheers, |
Yes, this has landed and you can get it by running |
Oops, I was wrong. It has not yet landed in npm. |
that's what I thought. Will the fix be pushed to npm any time soon? |
thanks @petebacondarwin |
Is this fix available in npm yet? Or is there a timeline for when that will happen? |
0.2.0 has not yet been released. The timeline is the next few days, I believe |
#6978 - has now been merged into master |
I'm trying to find registry information about @angular/router but I don't understand the syntax. There's nothing I can find in the NPM registry (https://www.npmjs.com/package/angular) and the repository https://github.com/angular/router has not this tags you're mentioning. It has some but very old. Can anyone clarify this, and explain how to find this package information in the npm registry? Thanks a lot! :) |
Right now the versions on npm are not that useful: latest 0.0.1 and pre-release 0.1.0. The npm repository website doesn't like scope modules (e.g. those starting with The https://github.com/angular/router repository is obselete so ignore it. |
I'm having issues getting |
We are currently undertaking a design review of the component router. Please watch this space over the next couple of weeks |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
In my application in Angular 1, when I use the property 'template' in the directive, $onActivate works fine. But when I use the property 'templateUrl', $onActivate doesn't work (but the template is displayed fine).
Exemple :
Is it a bug ?
The text was updated successfully, but these errors were encountered: