我似乎无法弄清楚如何使我的ng-repeat工作

时间:2017-12-10 08:39:59

标签: angularjs angularjs-ng-repeat

ng-repeat在chrome inspect

上被注释掉了

我似乎无法弄清楚如何让我的ng-repeat工作。我可以看到正确的信息是正确的,但是当我在开发工具中检查HTML时,下面的第一行被注释掉,并且卡片没有显示出来。有什么建议?

<div ng-repeat="matchedArtist in matchedArtists">
    <div class="centerPandora">
      <div class="row">
        <div class="col-med-12">
          <div class="content">
            <div class="card">
              <div class="firstinfo">
                <img src="#" />
                <div class="profileinfo">
                  <h1>{{ matchedArtist.artist }}</h1>
                  <h3>{{ matchedArtist.date }}</h3>
                  <h4>{{ matchedArtist.venue }}</h4>
                  <p class="bio"></p>
                  <a href="#">
                    <font color="black">Click for event details</font>
                  </a>
                </div>
              </div>
            </div>
            <div class="badgescard info"><span id="days"></span><span 
id="hours"></span><span id="minutes"></span><span id="seconds"></span>
            </div>
          </div>
        </div>
      </div>
    </div><br /><br /><br /><br />
  </div>
'use strict';

var concertList = 
angular.module('concertList').controller('ConcertListCtrl', 
function($scope){
    function hideLogin($scope) {
        $scope.advstatus = true;
    };
    $scope.matchedArtists = matchedArtists
});

更新

Here is a screenshot of the AngularJS scope showing events are being scoped properly

1

2 个答案:

答案 0 :(得分:1)

首先,您必须确保您的控制器正常工作并进入html模板。

比$ scope.matchedArtists - 在你的情况下是一个对象数组

$scope.matchedArtists = [{artist: 'ártist', date: 'date', venue: 'venue '},
{artist: 'ártist2', date: 'date2', venue: 'venue2'}]

答案 1 :(得分:0)

调试AngularJS问题

快速测试范围变量:

matchedArtists={{matchedArtists | json}} scope={{$id}}
<div ng-repeat="matchedArtist in matchedArtists">
    <div class="centerPandora">
      <div class="row">
        <div class="col-med-12">

使用检查控制台,单击感兴趣的元素:

>scope=angular.element($0).scope()
>console.dir(scope)

数据未显示有几种可能的原因:

  1. 模板是隔离范围的一部分;
  2. 控制器位于兄弟元素上;
  3. 控制器使用controllerAs语法实例化;