如何implment A"加载更多"分页在Angularjs没有NG-重复? [英] How to implment a "Load more" pagination in Angularjs without ng-repeat?

查看:117
本文介绍了如何implment A"加载更多"分页在Angularjs没有NG-重复?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于NG-重复重绘像模型改变事件的所有项目,这将是一个更好的方法来在angularjs实施加载更多的行为/分页?

Since ng-repeat redraws all items on events like model change, what would be a better approach to implementing a "load more" behavior/pagination in angularjs ?

推荐答案

你到底是看到的,让你想避免 ngRepeat ?我起草了一个简单的例子,说明了什么得到重绘,什么不可行:

What exactly are you seeing that makes you want to avoid ngRepeat? I've drafted up a simple example that illustrates what gets redrawn and what doesn't:

例1: http://jsfiddle.net/langdonx/uf2C9/

如果您检查控制台,你会看到,当您单击添加按钮到另一个项目添加到模型中,只有新加入的项目被渲染。

If you check the console, you'll see that when you click the add button to add another item to the model, only the newly added item gets rendered.

例2: http://jsfiddle.net/langdonx/uf2C9/2/

操纵模型中的每一个项目,仍然没有重绘整个 ngRepeat ,它只是更新它所需要。

Manipulating every item in the model, still doesn't redraw the entire ngRepeat, it just updates what it needs to.

例3: http://jsfiddle.net/langdonx/uf2C9/1/

要帮助说明例2是合理的,我加了 {{} item.name} 到图像的src只是为了确保它会改变(这确实)

To help illustrate that Example 2 is sound, I added {{item.name}} to the image's src just to make sure it would change (which it does).

那么究竟是你想避免?

这篇关于如何implment A"加载更多"分页在Angularjs没有NG-重复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆