I have a problem with filling all available space with the router-outlet.
I use angular/flex-layout for my application. And the component loaded with the router doesn't take all available place.
<div fxLayout="column" fxFlexFill>
<maat-top-bar></maat-top-bar>
<router-outlet fxFlex></router-outlet>
</div>
Screenshot of app & dom
The router-outlet take space instead of child component. On screenshot the component is <maat-home></maat-home>
. In the DOM tree this component is placed after the router-outlet.
What can I do so the component <maat-home></maat-home>
will take the remaining space?
Thanks!
Angular 7.2. 0 introduced a new way to pass data using State Object while navigating between routed components. The benefit of using a state object is that you can share data between routed components with routeParams without displaying it on the URL segment, unlike queryParams in Angular.
You can add multiple outlets in your Angular application which enables you to implement advanced routing scenarios. Any component that gets matched by the Router will render it as a sibling of the Router outlet.
Router-Outlet is an Angular directive from the router library that is used to insert the component matched by routes to be displayed on the screen.
I found a way.
The router-outlet is hidden and the component added on DOM have the attribute fxFlexFill
for filling all available space.
<div fxLayout="column" fxFlexFill>
<maat-top-bar class="top-bar"></maat-top-bar>
<div fxFlex>
<router-outlet class="hidden-router"></router-outlet>
</div>
</div>
The class hidden-router
.hidden-router {
flex: 1 1 auto;
display: flex;
overflow: hidden;
}
And the component
<div fxFlexFill="">
I filling all remaining space
</div>
Adding fxFlex
to the <router-outlet>
is probably not what you want.
The component added by the router is added as a sibling, not as a child of <router-outlet>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With