2014-02-20 43 views
1

我有下面的代码,它显示了发布到Firebase的任何内容。Angular fire,nested ng-repeat

var app = angular.module("myapp", ["firebase"]); 
function MyController($scope, $firebase) { 
    var ref = new Firebase("....."); 
    $scope.messages = $firebase(ref.endAt().limit(100)); 
} 

<div ng-app="myapp"> 
     <div id="links" ng-controller="MyController">     
      <a ng-repeat="msg in messages" href="{{msg.highResUrl}}" data-gallery> 
       <img src="{{msg.imgUrl}}" style="width: 140px"/> 
       <!--This repeat isn't working--> 
       <ul> 
         <li ng-repeat="tag in msg.tags">{{tag}}</li>      
       </ul> 

      </a> 
     </div> 
    </div> 

的数据是这样的:

{ 
"highResUrl" : "...", 
"Source" : "....", 
"title" : "Img", 
"tags" : [ "Tag1", "Tag2", "Tag3", "Tag4" ], 
"imgUrl" : "..." 
} 

所有其他数据的作品,除了在标签内NG重复。任何想法?

谢谢

+1

消息是一个数组?你可以在$ index'消息轨道中试试msg吗? –

+0

那么...什么不行?内在的重复做什么?任何错误? – Kato

回答

1

看看这个plunkr。它似乎适用于某些灯具数据。

测试数据:

$scope.messages = [{ 
        "highResUrl" : "", 
        "Source" : "", 
        "title" : "Img", 
        "tags" : [ "Tag1", "Tag2", "Tag3", "Tag4" ], 
        "imgUrl" : "" 
        }, 
        { 
        "highResUrl" : "", 
        "Source" : "", 
        "title" : "Img", 
        "tags" : [ "Tag1", "Tag2", "Tag3", "Tag4" ], 
        "imgUrl" : "http://devgirl.org/wp-content/uploads/2013/03/angular-logo.jpeg" 
        }, 
        { 
        "highResUrl" : "", 
        "Source" : "", 
        "title" : "Img", 
        "tags" : [ "Tag1", "Tag2", "Tag3", "Tag4" ], 
        "imgUrl" : "http://devgirl.org/wp-content/uploads/2013/03/angular-logo.jpeg" 
        }, 
        { 
        "highResUrl" : "", 
        "Source" : "", 
        "title" : "Img", 
        "tags" : [ "Tag1", "Tag2", "Tag3", "Tag4" ], 
        "imgUrl" : "http://devgirl.org/wp-content/uploads/2013/03/angular-logo.jpeg" 
        }]; 
+1

将所提供的数据放入Firebase中,适合我使用 - http://plnkr.co/edit/ZunRqZLrOuKxaiWa3OUo?p=preview –