page-router-outlet include component
See original GitHub issueI 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:
- Created 7 years ago
- Reactions:1
- Comments:13 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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 optionalextra-header
content. It’s true that the component get’s “recreated” each time, but it’s unnoticeable (Let shared angular service handle the logic).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)