angular - How to enable vertical scroll when more data is loaded in the sub component in form of gridcontrols?
问题描述
When i am opening the component there is a sub component that gets array of data objects through api. I need to enable scroll-vertical when the data returned is more than 5 and disable it when the data objects are less than 5.
解决方案
在这里,试试这个:
https://stackblitz.com/edit/angular-2wcotd
基本思想是使用 [ngClass] 条件
<div [ngClass]="{'temp':items.length > 5}">
<div *ngFor="let item of items">
{{item}}
</div>
</div>
<button (click)="add(3)" >Add</button>
<button (click)="remove()" >Remove</button>
在 css 中:
.temp{
max-height: 200px;
overflow-y:scroll;
}
推荐阅读
- javascript - 模块构建失败:错误:无法解析在引导版本配置为 v3 时必须安装的模块“bootstrap-sass”
- python - 熊猫如何在python中将同一列的所有元素相乘
- haskell - 有人可以在 Haskell 中解释这行代码吗
- python - python,matplotlib:我正在获取数组的值,而不是绘图
- python-sphinx - 如何在 Sphinx 侧边栏中删除“下一个/上一个主题”?
- javascript - 将自定义范围滑块划分为多个部分
- angular - 传入 MatAutoComplete 的 ng-content 不显示传入的选项
- python - 将递增的整数值分配给变量列表,而无需计算变量的数量
- flutter - Flutter中的ListView动态排序
- amazon-web-services - AWS EC2 实例状态检查正常,但服务器已消失