Search code examples
angularjshtmlrestangular

Restangular: Empty array using $object


I display my data in a table (smart-table) and everything is working well but in my angular code, when I try to get my "topicList" it's return an empty array. there is my code and thank you in advance.

$scope.topicList= Restangular.all("topic").getList().$object;
    for(var k in $scope.topicList) {
        console.log($scope.topicList[k]);
    if($scope.topicList[k] === "")
        {xxxx} 
    }

Solution

  • Restangular.all('topic').getList().then(function(response) {
      $scope.topicList = response;
      ...
    });
    

    After you've assigned the topicList then you can do your bits and pieces.