为什么不从我的对象中获取值?

时间:2016-08-01 11:04:49

标签: angularjs ionic-framework

由于某种原因,我无法循环通过我的对象。 数据绑定根本不起作用。我在不同的控制器中有完全相同的代码,并且它有效。

我的错误是什么?

我有这个控制器:

.controller('ListCtrl', function($scope, $http, $stateParams, $state, $timeout) {
  var catId = $stateParams.id;

  firebase.database().ref("list/" + catId.toLowerCase()).on('value', function(snapshot) {

    $timeout(function() {
      $scope.content = snapshot.val();
      $scope.test = $scope.content.name;
      console.log($scope.content);
      //returns object
      console.log($scope.test);
      //returns Barock
    })

  });

这个标记:

<div ng-repeat="cat in content" class="animated lightSpeedIn">
  <a ui-sref="list({id: cat.name})"nav-transition="none"><div ng-style="{'background': 'url(' + cat.bgurl + ')','background-repeat': 'no-repeat','background-size': 'cover','display': 'block','width': '100%','height': '25vh' }" class="bgcat center">
    <div class="inner">
      <h1 class="title_data">{{cat.name}}</h1>
      <h4>{{cat.subtitle}}</h4>
    </div>
  </div></a>
</div>
<h1>{{test}}</h1> <!-- NO DATA SHOWN -->

这是我得到的数据:

enter image description here

我对此观点的路线:

.state('list', {
      url: '/list/:id',
      templateUrl: 'templates/list.html',
      controller: "ListCtrl",
      cache: false
    })

0 个答案:

没有答案
相关问题