将 class 添加到特定的 ng-repeat 项目并留在该项目上
add class to a specific ng-repeat item and stay on that item
我正在开发一个聊天应用程序。 chatapp 中的消息使用 ng-repeat 填充。当用户注销应用程序或关闭应用程序时,我希望 ng-repeat 列表中的当前最后一项(消息)用 class 名称标记,并保留在该特定项(消息)中。这样当用户回来时,它可以看到他阅读的最后一条消息。
只有当新消息添加到列表时,我才可以用 class 名称标记最后一项(消息),class 名称总是在最后一项(消息)上.因此,总是会标记最后一项(消息),class 名称不会固定在该特定项(消息)上。
有人知道如何处理这个吗?
谢谢!
我自己解决的问题如下:
当应用程序进入后台时,我手动将一个项目插入到 ng-repeat。
这仅对特定用户可见。新消息将添加在此下方,因此用户可以看到他在哪里以及哪些消息是新消息。
//do something when app goes to the background
document.addEventListener('pause', function() {
$timeout(function(){
$scope.messages.push('messages below this line are new');
},0);
},false);
html:
<ion-item ng-repeat="message in messages">...</ion-item>
我正在开发一个聊天应用程序。 chatapp 中的消息使用 ng-repeat 填充。当用户注销应用程序或关闭应用程序时,我希望 ng-repeat 列表中的当前最后一项(消息)用 class 名称标记,并保留在该特定项(消息)中。这样当用户回来时,它可以看到他阅读的最后一条消息。
只有当新消息添加到列表时,我才可以用 class 名称标记最后一项(消息),class 名称总是在最后一项(消息)上.因此,总是会标记最后一项(消息),class 名称不会固定在该特定项(消息)上。
有人知道如何处理这个吗?
谢谢!
我自己解决的问题如下:
当应用程序进入后台时,我手动将一个项目插入到 ng-repeat。 这仅对特定用户可见。新消息将添加在此下方,因此用户可以看到他在哪里以及哪些消息是新消息。
//do something when app goes to the background
document.addEventListener('pause', function() {
$timeout(function(){
$scope.messages.push('messages below this line are new');
},0);
},false);
html:
<ion-item ng-repeat="message in messages">...</ion-item>