In the server response, I have an array of objects that I am trying to iterate over using ng-repeat
in order to read each value.
While trying to use array[0].value
works fine, things are not going as expected when using ng-repeat
.
Despite all my efforts in debugging, I still can't grasp how ng-repeat is functioning with arrays.
Take a look at this example:
The messages array:
[
{"Id":14,"Text":"hii hello","count":750},
{"Id":10009,"Text":"test message","count":6}
]
This is what I'm using in the HTML:
<div class="my-message" layout="row" layout-align="center center">
{{messages}} <!-- printing the above array -->
<div ng-repat="message in messages">
{{ message.Id}}<!-- nothing is being printed -->
</div>
{{ messages[0].Id }} <!-- printing 14 !-->
</div>
The array is within scope and visible in the HTML since the {{ message }} array is printing correctly.
If anyone could shed some light on how ng-repeat works and where I might be going wrong, I'd greatly appreciate it.