Ng-repeat not working表达式显示然后立即消失

时间:2016-02-21 08:47:04

标签: javascript angularjs angularjs-ng-repeat

我正在使用ng-repeat在此页面上创建用户列表。刷新页面时,应该出现的表达式会在一瞬间显示,然后消失,不会有任何应该重复的对象的痕迹。这是代码

<div class="row" data-ng-controller="createUserProfileController as dashboard">
    <h2 class="text-center">Find Students Near By</h2>
    <hr />
                <div class="col-md-6" id="map-canvas"></div>

    <div class="col-md-4 pull-right">
        <div class="panel-success">
            <div class="panel-heading">
                <h3 class="text-center">List of Datalus Users</h3>
            </div>
            <hr />
            <div ng-repeat="userProfile in dashboard.items" class="panel">
                <div class="panel-heading">
                    <h4 class="panel-title text-center">
                        <a data-parent="#accordion1" href="/courses/moreinfo/{{userProfile.id}}">
                            {{userProfile.firstName}}
                        </a>
                    </h4>
                </div>
            </div>
        </div><!-- /.cols -->
    </div>
</div>

1 个答案:

答案 0 :(得分:0)

在您的代码中没有错误。您可能正在从其他地方进行更改。 Here我在jsfiddle中实施了您的代码。

angular.module("app", [])
.controller("createUserProfileController", ["$scope", function($scope){
  var c = this;
  c.items = [
    {
      id: 1,
      firstName: 'hello'
    }, {
      id: 2,
      firstName: 'bufellow'
    }
  ];
}]);