- 角度材质教程
- 角材料 - 主页
- 角度材料 - 概述
- 环境设置
- 角度材质 - 自动完成
- 角材料 - 底板
- 角度材料 - 卡片
- Angular 材质 - 小部件
- Angular 材质 - 布局
- 角度材质 - 输入
- 角度材质 - 图标
- 角度材质 - 网格
- 角度材质 - SideNav
- Angular Material - Fab 快速拨号
- 角度材料 - 副标题
- 角度材质 - 滑动
- 角材料 - 开关
- Angular 材质 - 主题
- 角度材料 - 吐司
- 角度材料 - 版式
- 角度材质 - 虚拟重复
- 角材质 - WhiteFrame
- 角度材质有用资源
- 角度材质 - 快速指南
- 角度材料 - 有用的资源
- 角度材料 - 讨论
角度材质 - 虚拟重复
md -virtual-repeat-container是 md-virtual-repeat 组件的滚动容器。
属性
下表列出了md-virtual-repeat-container的参数和不同属性的说明。
| 先生编号 | 参数及说明 |
|---|---|
| 1 | md-顶部索引 将滚动容器顶部的项目的索引绑定到 $scope。它既可以读取也可以设置滚动位置。 |
| 2 | md-东方-水平 确定容器是否应水平滚动(默认为方向并垂直滚动)。 |
| 3 | md-自动收缩 如果存在,当物品数量小于其原始尺寸时,容器将缩小以适应物品数量。 |
| 4 | md-自动收缩最小 md-auto-shrink 将收缩到的最小项目数(默认值:0)。 |
md-虚拟重复
Virtual Repeat 是 ng-repeat 的替代品,仅渲染足够的 html 元素来填充容器并在用户滚动时重用它们。
属性
下表列出了md-virtual-repeat的参数和不同属性的说明 。
| 先生编号 | 参数及说明 |
|---|---|
| 1 | md 商品尺寸 重复元素的高度或宽度(每个元素必须相同)。这是可选的。如果丢失,这会尝试从 dom 读取大小,但仍然假设所有重复节点具有相同的高度或宽度。 |
| 2 | md 额外名称 计算为可在重复范围内将当前迭代项分配给的附加名称(需要在 md-autocomplete 中使用)。 |
| 3 | MD点播 如果存在,则将md-virtual-repeat参数视为可以获取行而不是数组的对象。该对象必须使用两 (2) 种方法实现以下接口 -
|
例子
以下示例展示了虚拟重复的使用。
am_virtualrepeat.htm
<html lang = "en">
<head>
<link rel = "stylesheet"
href = "https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.css">
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-animate.min.js"></script>
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-aria.min.js"></script>
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-messages.min.js"></script>
<script src = "https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.js"></script>
<link rel = "stylesheet" href = "https://fonts.googleapis.com/icon?family=Material+Icons">
<style>
.vrepeatContainer #horizontal-container {
height: 100px;
width: 830px;
}
.vrepeatContainer #vertical-container {
height: 292px;
width: 400px;
}
.vrepeatContainer .repeated-item-horizontal {
border-right: 1px solid #ddd;
box-sizing: border-box;
display: inline-block;
height: 84px;
padding-top: 35px;
text-align: center;
width: 50px;
}
.vrepeatContainer .repeated-item-vertical {
border-bottom: 1px solid #ddd;
box-sizing: border-box;
height: 40px;
padding-top: 10px;
}
.vrepeatContainer md-content {
margin: 16px;
}
.vrepeatContainer md-virtual-repeat-container {
border: solid 1px grey;
}
</style>
<script language = "javascript">
angular
.module('firstApplication', ['ngMaterial'])
.controller('vrepeatController', vrepeatController);
function vrepeatController ($scope) {
this.items = [];
for (var i = 0; i < 1000; i++) {
this.items.push(i);
}
}
</script>
</head>
<body ng-app = "firstApplication">
<div class = "vrepeatContainer" ng-controller = "vrepeatController as ctrl"
ng-cloak>
<md-content layout = "column">
<h2>Horizontal Repeat</h2>
<md-virtual-repeat-container id = "horizontal-container" md-orient-horizontal>
<div md-virtual-repeat = "item in ctrl.items"
class = "repeated-item-horizontal" flex>
{{item}}
</div>
</md-virtual-repeat-container>
<h2>Vertical Repeat</h2>
<md-virtual-repeat-container id = "vertical-container">
<div md-virtual-repeat = "item in ctrl.items"
class = "repeated-item-vertical" flex>
{{item}}
</div>
</md-virtual-repeat-container>
</md-content>
</div>
</body>
</html>
结果
验证结果。