question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

page-router-outlet include component

See original GitHub issue

I am trying to include a component on every page. With regular angular I’d do it this way: <router-outlet></router-outlet><my-component></my-component> This works, but navigation back doesn’t work (this is to be expected) I cannot substitute router-outlet with page-router-outlet, because my-component isn’t present then (according to documentation, this is also expected behavior). Can you please suggest a solution? I asked on SO, but had no luck there also.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
orgbxcommented, Nov 29, 2016

Hey @lukashlobil, check this solution using angular’s content projection, it may fit your needs. It’s a shared component, showcase-layout.component, that wraps each page such as this one to have a more DRY solution. In this case, it receives a title and can have an optional extra-header content. It’s true that the component get’s “recreated” each time, but it’s unnoticeable (Let shared angular service handle the logic).

1reaction
lukashlobilcommented, Nov 29, 2016

Thank you for thorough response. I had to make sure I am not overlooking anything. So I basically had to hear: “you have to do it this way”. What gave me the drive to look into this deeper was the usage of router-outlet, which worked as I expected from web development (minus the back navigation) - I understand, in native terms when I used router-outlet and navigated, the content just got switched and no navigation took place. So when I pressed back, there was nothing in history and application closed itself. Makes sense. Thank you for taking the time to make it clear for me that this is “by design”.

(Would be a cool feature though)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Common Routing Tasks - Angular
For the component property, you can define any component in your application. Common choices include an application-specific PageNotFoundComponent , which you ...
Read more >
A Complete Guide To Routing In Angular - Smashing Magazine
Angular Router supports multiple outlets in the same application. A component has one associated primary route and can have auxiliary routes ...
Read more >
How to add a top level router outlet in Angular - Stack Overflow
Okay, I believe all you need to do, is move all that code to the component BoardComponent and leave only <router-outlet></router-outlet> in app....
Read more >
Angular Router Tutorial - CodinGame
Step 1: Install The Angular Project. · Step 2: Make three components for the application. · Step 3: Routing and Navigation. · Step...
Read more >
Angular Routing With Splitter Component
The Angular project will contain one Splitter component with two Splitter Items. Each of them will have a router-outlet that will be used...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found