0

I am using firebase to get some data and display it, My issue that i cant see my list on the template. My factory is

 return $firebaseArray(itemsRef);

and my object on firebase is

{
  "contacts" : [ {
    "active" : true,
    "lastName" : "fdg",
    "name" : "sdfdsf",
    "number" : "052045454",
    "table" : 3
  }]}

and the controller is

 $scope.contacts =Items;

and display it just :

ng-repeat="(key, contact) in contacts 

what can be the issue? i can see that firebase it return data...

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Vitaly Menchikovsky
  • 7,684
  • 17
  • 57
  • 89
  • Items is a factory that return firebase object ....controller("ListCtrl", function($scope, Items) { $scope.items = Items; – Vitaly Menchikovsky May 24 '16 at 09:17
  • Could you provide a plunker, or at least more code? Looking at this makes many things appear possibly incorrect. For instance, it looks like the template is incorrect, and possibly has a solution in: http://stackoverflow.com/questions/15127834/how-can-i-iterate-over-the-keys-value-in-ng-repeat-in-angular – Brian May 24 '16 at 09:18
  • `Console.log($scope.items)` to check whether factory returns the correct data. – Sajal May 24 '16 at 09:19
  • [{"active":true,"lastName":"fdg","name":"rimsdcan","number":"052045453","table":3}] – Vitaly Menchikovsky May 24 '16 at 09:33
  • If `{ "contacts" : [ { "active" : true, "lastName" : "fdg", "name" : "sdfdsf", "number" : "052045454", "table" : 3 }]}` is your `Items`, then you should use `$scope.contacts = Items.contacts`. – Achu May 24 '16 at 09:37

1 Answers1

0

Yeah, there are multiple things that look wrong in the question. But I suspect most likely issue is that contacts is an array, not map. So, what you need to do most likely is something along these lines:

<div ng-repeat="contact in contacts track by $index">
Active: {{contact.active}}, Contact Name: {{contact.name}} ...
</div>

Or these (note the indexed access):

<div ng-repeat="(key, value) in contacts[0]">
key: {{key}}, Value: {{value}} ...
</div>

P.S. "track by $index" part may or may not be required depending on your data.

Seva
  • 2,388
  • 10
  • 9