【问题标题】:Angular fire, nested ng-repeat角火,嵌套 ng-repeat
【发布时间】:2014-02-20 08:32:49
【问题描述】:

我有以下代码显示发布到 Firebase 的任何内容。

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-repeat。有什么想法吗?

谢谢

【问题讨论】:

  • messages 是一个数组?你可以试试msg in messages track by $index 吗?
  • 那么......什么不起作用?内部 ng-repeat 有什么作用?有什么错误吗?

标签: javascript html firebase angularfire


【解决方案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"
                  }];

【讨论】:

猜你喜欢
  • 2015-04-19
  • 2015-09-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-13
  • 1970-01-01
相关资源
最近更新 更多