E
E
Egor2015-01-30 22:46:39
JavaScript
Egor, 2015-01-30 22:46:39

Angularjs. How to remove variables from scope and still leave layout?

Greetings.
Let's say we have a chat in Angular.
Messages are stored in the $scope.messages array. Let the maximum size of this array be 100 messages. Is it possible to replace the old messages in the array with the new ones so that users can see the old messages as well. That is, old messages should not be removed from the DOM.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2015-01-30
Protko @Fesor

Yes, you can write your own directive that implements this behavior. Another question is why? Usually the problem is not the number of array elements, but the number of DOM elements.

A
Alexander, 2015-02-01
@AlexanderKot

It seems to me that this is against the concept of angular. It's probably better to mark some messages in $scope.messages as new, adding them to the old ones.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question