【发布时间】:2019-03-31 04:01:23
【问题描述】:
我正在使用 3 个组件:
<menu (setAnimal)='setAnimal($event)' ></menu>
//principalComponent
<router-outlet (activate)='onActivate($event)'></router-outlet>
<footer></footer>
红色边框组件称为PrincipalComponent (<router-outlet>),它应该具有移除页眉和页脚占用空间后的可用高度。如何使PrincipalComponent 包含可用空间的总高度?
这是我的代码:
https://stackblitz.com/edit/angular-8tgjnk?file=app/principal.component.ts
import { Component, Input } from '@angular/core';
@Component({
selector: 'principal',
template: '<div style="height:100%;border:1px solid red;"> outer-
outlet</div>',
styles: [`h1 { font-family: Lato; }`]
})
@Component({
selector: 'menu',
template: `<div style='border:1px solid blue; height:100px'>THIS IS THE
MENU</div>`,
styles: [`h1 { font-family: Lato; }`]
})
@Component({
selector: 'footer',
template: `<div style='border:1px solid green'><h1>THIS IS THE FOOTER
</h1> </div>`,
styles: [`div{position: absolute;bottom: 0;width: 100%;}`]
})
【问题讨论】:
-
如果你在里面设置一些组件,我认为你不需要它会自动调整
-
怎么样???我不明白
-
路由出口被您在运行时为路由器指定的模块替换,然后路由器将伸展以包含这些模块
-
@jonathanHeindl 那我该怎么办?我不知道。
-
阅读这个:angular.io/tutorial/toh-pt5 特别是 AddRoutes
标签: angular