html - AngularJS ng-repeat with track overwriting array -


i'm using ng-repeat render conversation-style in ionic app. i'm using track ($index + message._id), same result using track $index.

the problem have array of messages wich contains text , of them html linked via ng-bind-html.

when more 1 message html appears in array (pushed array doing $scope.messages.push(message)) previous elements html content being overwritten las message html content.

how can avoid behaviour? i'm trying not being successful. think strange behaviour. been working angularjs year , never got this.

example:

<div ng-repeat="message in chat.messages track ($index + message._id)">   <div class="message" ng-bind-html="message.content"></div> </div> 

and in javascript, when message arrives (message can plain text or html content):

 $scope.messages.push(message); 

even if delete ng-bind-html , make {{message.content}} html presented plain text changes in array elements. every message has $index , unique _id, me kind of strange. in every message there internal index (made me) in case of messages being overwritten same. example, first message rendered:

message1 = {   "_id": "56e6c0edd4c6df358bada4ec",    "index": 71,    "type": "trip",    "comment": "nothing here",    "username": "alwaysthesame",    "has_user_input": false,    "nextindex": 40,    "user_inputs": [ ],    "mood_0": [ ],    "content": irrelevant html content }  message2 = {   "_id": "56e6c0edd4c6df358bada4ed",    "index": 71,    "type": "trip",    "comment": "nothing here",    "username": "alwaysthesame",    "has_user_input": false,    "nextindex": 40,    "user_inputs": [ ],    "mood_0": [ ],    "content": other irrelevant html content } 

so element in common messages being overwritten index property of object.

thank much!!


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -