limitTo不NG-重复的工作中AngularJs [英] limitTo not working in ng-repeat in AngularJs
本文介绍了limitTo不NG-重复的工作中AngularJs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我工作了一些code一些应用。
我想在聊天限制的消息
I am working out some code for some application. I want to limit the messages in the chat
this.limitM = -10;
$scope.msgsCount = //contains the number of messages
<button ng-if="msgsCount > -main.limitM"
ng-click="main.limitM=-10+main.limitM">Load More</button>
<li class="singleMessage clearfix"
ng-repeat="msg in chat.msgs | limitTo:main.limitM"
ng-class="::{myMessage: msg.senderName != chat.name}">
<img class="profileImage" alt="::{{chat.name}}" width="40px">
<p ng-bind-html="parseMsg(msg)"></p>
</li>
这不是限制性的消息,显示所有的消息。
谁能帮助?
This is not limiting the messages, all the messages appear. Can anyone help ?
推荐答案
首先,你必须定义所有必需的变量,使其工作。结果
控制器的例子:
First you have to define all necessary variables to make it work.
Example of your controller:
$scope.limit = 3;
$scope.expand = function(limit) {
$scope.limit += limit;
}
$scope.chat = ['one', 'two', 'three', 'four', 'five', 'six', 'seven'];
和看法:
<button ng-if="chat.length > limit" ng-click="expand(limit)">Load More</button>
<li ng-repeat="msg in chat | limitTo : limit" >{{ msg }}</li>
下面是一个简单的 普拉克 已经做了你所需要的。
Here is a simple plunk, that does what you need.
这篇关于limitTo不NG-重复的工作中AngularJs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文