ngRepeat不显示元素

时间:2017-08-11 08:51:28

标签: javascript html angularjs

我正在使用Angular进行项目,但ngRepeat似乎没有用。这是代码:

HTML code:

<ion-content>
<ul class="list">
    <li ng-repeat="r in res" class="item">
      <h2>{{r.name}}</h2>
      <p>{{r.locality}}</p
    </li>
</ul>
</ion-content>

JS代码:

 var user = $state.params.user;
 var whereClause = "agent_email = '" + user.email + "'";
 var queryBuilder = Backendless.DataQueryBuilder.create().setWhereClause( whereClause );
 Backendless.Data.of("Hotels").find( queryBuilder )
.then(function(foundHotels) {
  $scope.res = foundHotels;
  console.log($scope.res);
  console.log($scope.res[0].name);
  console.log($scope.res[1].name);
})
.catch(function(error) {
  console.log("error" + error.message);
})

Backendless返回一个包含所有值的数组。它在控制台中返回正确的值,但ng-repeat部分不起作用。我检查了Chrome上的元素,ng-repeat部分转换为:<!-- ngRepeat: r in res -->。出了什么问题?

console.log(res)示例:

[DataStore.model]
 0: DataStore.model
 agent_email: "a@b.com"
 amenities: "example"
 city: "bangalore"
 name: "jw marriott"
 // other parameters
 1: DataStore.model
 agent_email: "a@b.com"
 amenities: "example"
 city: "bangalore"
 name: "fairfield marriott"
 //other parameters
length: 2

0 个答案:

没有答案