首先使用这个插件:
https://github.com/zedwang/angular-waterfall
更改部分代码,获得兼容性
if (scope.$last === true) {
angular.element(element).ready(function() {
var img = element.find("img")[0];
var oImage = new Image();
if (oImage.complete) {
//$timeout.cancel();
//$timeout(function(){
scope.$emit("waterfall:repeatFinished");
//},500);
}else {
oImage.onload = function () {
scope.$emit("waterfall:repeatFinished");
};
}
oImage.src = img.src;
});
}
$rootScope.$on("waterfall:repeatFinished",function(){
$timeout.cancel();
$timeout(function(){
waterfall(scope.minCols);
},500)
});
如果不需要点击按钮加载更多功能,则下拉刷新和上拉加载依旧使用ionic指令,不过要注意上拉加载的触发需要在数据变更后加一段时间的延迟