'Angular router-outlet chilld doesn't take all width
I have a router outlet in a component. The child component doesn't take the whole width. I tried to give to the child's div width:100%, min-width:100%, also with !important, but it's not working. How can I force the child's div to take the whole width available? Parent HTML:
<div fxLayout="column" fxLayoutAlign="space-between stretch">
<div>
...
</div>
<div fxLayout="row" fxFlexFill>
<div class="navbar" fxLayout="column">
</div>
<div class="mainDiv" fxFlex>
<router-outlet></router-outlet>
</div>
</div>
<div fxLayoutAlign="end"></div>
</div>
Parent CSS:
.navbar {
padding-top: 40px;
padding-right: 80px;
border-top: none;
}
.mainDiv {
width: 100%;
border-top: none;
}
Child CSS:
<div class="container">...</div>
Solution 1:[1]
Try set the router-outlet inside a div without using flex:
<div style="width: 100%;height: 100%">
<router-outlet ></router-outlet>
</div>
Solution 2:[2]
One of the best things about ember data is changes you make to a model anywhere in your app take effect everywhere. So I'd solve this by applying multiple getters in the same component and passing in the full list of tasks from the route. Then when isOpen or the filter criteria or whatever updates the getter will refresh and you'll get new data in the template.
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
export default class TaskListComponent extends Component {
@tracked filterBySomething;
get openTasks() {
return this.args.tasks.filterBy('isOpen');
}
get filteredTasks() {
return this.openTasks.filter((task) => {
return task.hasSomething === this.filterBySomething;
});
}
}
With a template like
{{#each this.filteredTasks as |task|}}
{{task}}
{{/each}}
Which would be called from a route template as:
<TaskList @tasks={{@model}} />
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Bounguicha Khmayes |
| Solution 2 | jrjohnson |
