角度js数据现在显示在前端

时间:2018-01-11 01:44:52

标签: angularjs

数据显示在日志中,但现在显示在我的页面中。我想加载数据。有什么问题?

function AppController($scope, TestFactory) {
  /* console.log("AppController is now available.");*/
  $scope.testdata= [];
  TestFactory.getData().then(function(response) {
    $scope.testdata = response.data;
    console.log("Data:", $scope.testdata);
  })
}


<ion-slide-page ng-repeat="event in testdata">
              <div class="now-viewport">
                <div class="event-image">

                </div>
                <div class="event-placeholder">
                  <div class="event-title">{{ event.message}}</div>
                  <div class="event-details">


                  </div>
                </div>
              </div>
            </ion-slide-page>

2 个答案:

答案 0 :(得分:1)

尝试下面的代码

<ion-slide-page ng-repeat="event in testdata.message">
   <div class="now-viewport">
      <div class="event-image">
          <div class="event-placeholder">
             <div class="event-title">{{event}}</div>
             <div class="event-details"></div>
          </div>
      </div>
    </div>
 </ion-slide-page>

答案 1 :(得分:0)

您的回复是 object ,其中 message 字符串的数组,请尝试以下操作,< / p>

<ion-slide-page ng-repeat="event in testdata.message">
   <div class="now-viewport">
      <div class="event-image">
          <div class="event-placeholder">
             <div class="event-title">{{event}}</div>
             <div class="event-details"></div>
          </div>
      </div>
    </div>
 </ion-slide-page>