ng-repeat不从indexeddb渲染元素

时间:2014-11-09 13:14:35

标签: javascript html angularjs

我正在尝试从索引数据库填充html页面上的元素,因为我使用了控制器,如下所示

myapp.controller('mainController', function($scope) {

   $scope.message = "Hello world";
   $scope.name = "sathya"
   $scope.projects = [];
   var prolist = [];
   var sdb = new SDB();
   sdb.On("project", "read", null, function(Store, data) {
       Store.openCursor().onsuccess = function(event) {
           var cursor = event.target.result;
           if (cursor) {
               prolist.push(cursor.value);
               cursor.continue();
           }
       }
   });
   console.log(prolist);
   $scope.projects = prolist;
});

HTML代码如下所示:

   <ul class="list-group" id="project-list">
   <li class="list-group-item" ng-repeat="project in projects">
        <a href="">{{project.projectname}}</a>
   </li>
   </ul>

在chrome控制台中,我获得了prolist变量的值:

Array[4] 0: ObjectisActivated: falseprojectdescription: "changed"projectid: 1 projectname: "hellothisissathya"__proto__: Object1: ObjectisActivated: trueprojectdescription: "second project"projectid: 2 projectname: "hello"__proto__: Object 2: ObjectisActivated: trueprojectdescription: "second project"projectid: 3 projectname: "hello"__proto__: Object 3: ObjectisActivated: trueprojectdescription: "second project"projectid: 4 projectname: "hello"__proto__: Objectlength: 4__proto__: Array[0] 

但是在html中它没有从每个对象渲染项目名称。

我需要用这个数组填充scope.projects列表。

0 个答案:

没有答案