0

I am loading data dynamically to ng-repeat so once i receive data its not binding it to ul , i know sometime it happens if you have duplicate indexes but in below case i am not sure what is happening, Any idea ?

main.html

<div> <ul ng-repeat="message in data track by index"> <li>{{message}}</li> </ul> </div> 

ctrl.js

angular.module('loggingApp').controller('DitCtrl',function ($scope,DitFactory) { 'use strict'; DitFactory.getLogs().then(function (response) { $scope.data = response.data; console.log($scope.data); }); }); 

console.log

printing data in console ["test.txt", "test1.txt", "test2.txt", "test3.txt", "test4.txt"] 
3
  • Did you try ng-repeat="message in $scope.data track by index" ? Commented Jun 30, 2016 at 16:38
  • nope its not displaying anything Commented Jun 30, 2016 at 16:40
  • try $scope.data.messageData = response.data; and ng-repeat="message in data.messageData track by index" Commented Jun 30, 2016 at 16:43

1 Answer 1

5

Your ng-repeat needs to look like this:

ng-repeat="message in data track by $index" 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.