【发布时间】:2016-09-20 08:13:57
【问题描述】:
我正在使用 angular-material 0.11.2 并尝试用虚拟重复制作一些东西。
代码的html部分是
<div layout="row" flex class="md-padding" style="padding-bottom:0;">
<md-input-container>
<div layout="row">
<div layout="column">
<label>Arama</label>
<input ng-model="searchCriteria" style="width:300px !important;" type="text">
</div>
<div layout="column" flex>
<div layout="row">
<md-checkbox class="md-primary" ng-model="filterLocal" aria-label="Local" ng-change="">
Merkez Birimler
</md-checkbox>
</div>
</div>
</div>
</md-input-container>
</div>
<md-content class="md-padding divInfiniteScroll" layout="column">
<md-virtual-repeat-container id="distributionItemInfiniteScrollContainer" flex>
<div md-virtual-repeat="item in testData" md-on-demand class="repeated-item" flex>
{{item.Id}}
</div>
</md-virtual-repeat-container>
</md-content>
而javascript部分是;
$scope.testData = {
numLoaded_: 0,
toLoad_: 0,
items: [],
// Required.
getItemAtIndex: function(index) {
if (index > this.numLoaded_) {
this.fetchMoreItems_(index);
return null;
}
return this.items[index];
},
// Required.
// For infinite scroll behavior, we always return a slightly higher
// number than the previously loaded items.
getLength: function() {
return this.numLoaded_ + 10;
},
fetchMoreItems_: function(index) {
if (this.toLoad_ < index) {
this.toLoad_ += 10;
var searchObject= {};
searchObject.SearchCriteria = $scope.searchCriteria;
searchObject.Local = $scope.filterLocal;
var that = this;
$myService.search(searchObject, index).then(function complete(data) {
that.items = that.items.concat(data);
that.numLoaded_ = that.toLoad_;
});
}
}
};
我想用复选框状态和文本元素中的数据过滤虚拟滚动数据。例如,最初 virtual-repeat 有 1000 行,包括本地和远程,如果我选中复选框,则仅从服务(远程 db)获取本地,如果取消选中同时获取两者。或者在输入中写一些东西,必须再次更改数据。但我没有任何想法去做。该文档也不包含有关此的任何信息,您知道吗?请提供一些信息给我。谢谢。
【问题讨论】:
标签: angularjs filter material-design infinite-scroll