Skip to content
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

rc-0: Extending router-outlet with deprecated router fails silently #8427

Closed
CaptainCodeman opened this issue May 3, 2016 · 13 comments
Closed

Comments

@CaptainCodeman
Copy link

Steps to reproduce and a minimal demo of the problem
See plunker:
http://plnkr.co/edit/wiyXdxEMQ2hV8wI9frwn?p=preview

Current behavior
No <custom-router> outlet rendered

Expected/desired behavior
<custom-router> outlet is rendered

Other information
This is commonly used for adding security to routes and worked upto latest RC-0
No error messages are displayed, the code fails silently and the component is never instantiated

@PinkTiu
Copy link

PinkTiu commented May 3, 2016

To fix your problem you can do this:
In your app.component.ts do another import import {RouterOutlet} from '@angular/router-deprecated'; rename <custom-outlet></custom-outlet> to <router-outlet></router-outlet>. Change your directives to directives: [ROUTER_DIRECTIVES.filter(direc => direc != RouterOutlet), CustomOutlet]

For me this works.

@CaptainCodeman
Copy link
Author

Thanks @PinkTiu

I tried it and It kind of works, in that the component gets instantiated, but unfortunately none of the extra services my app uses are injected into it - like it sees it as RouterOutlet and nothing more.

I'll have a play around with it and see if I can solve the DI part.

@sonicoder86
Copy link

If you don't modify the name of the selector it works for me: https://github.com/blacksonic/angular2-esnext-starter/blob/master/client/app/auth/directives/router_outlet.js

@CaptainCodeman
Copy link
Author

Thanks @BlackSonic that approach seems to do the trick - using the same selector and also adding the static get parameters() method

@sonicoder86
Copy link

The static get parameters() is only necessary for Javascript as far as i know, Typescript should work with parameter decorators.

@CaptainCodeman
Copy link
Author

I'm using typescript but needed that as well.

@robwormald
Copy link
Contributor

Tracked this down in core, working on a PR to fix.

@ghaiat
Copy link

ghaiat commented May 3, 2016

i tried with RC1 and i m still facing the same issue : silent fail...

@Kevin-K
Copy link
Contributor

Kevin-K commented May 4, 2016

Updated from RC0 -> RC1:
When extending RouterOutlet without changing the selector name works for me.
I was able to remove the static get parameters() and still have my services DI work as expected.

@CaptainCodeman
Copy link
Author

It didn't work for me with a custom name so IMO it's still not really fixed properly - you could envisage a situation where you have a standard and custom outlet in a page which currently wouldn't be possible.

@benharrell
Copy link

was just able to get this working much like blacksonic's version (although his path change slightly from the link above) i had to use a diff selector name as well

@vsavkin
Copy link
Contributor

vsavkin commented Jul 6, 2016

We are no longer maintaining the deprecated router to focus our efforts on making the new router solid.

You can add security to routes by using guards instead of extending outlets in the new router. But you also should be able to extend outlets.

Closing this issue.

@vsavkin vsavkin closed this as completed Jul 6, 2016
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants