IndexedDB的回调angularjs不更新UI [英] IndexedDB callback not updating UI in angularjs

查看:197
本文介绍了IndexedDB的回调angularjs不更新UI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面库访问索引资料在Angularjs一个新的Chrome应用: https://开头的github .COM / aaronpowell / db.js

I am using the following library to access IndexedDB in Angularjs on a new Chrome App: https://github.com/aaronpowell/db.js

当我尝试通过使用此更新应用程序启动时的用户界面:

When I try to update the UI on App startup by using this :

db.orders.query().all().execute().done(function(results) { 
        $scope.ordercount = results.length;
});

在我的main.html中我已经使用了定单计数变量:

in my main.html I have used the ordercount variable as:

Orders : {{ordercount}}

然而,用户界面​​没有更新,除非我做NG单击或任何其他NG- *事件。所有我需要的是被载入我的应用程序时显示的订单数量。我试过$ scope.apply(),但它引发错误说适用()不可用。

However, the UI is not updating unless I do ng-click or any other ng-* events. All I need is to show number of orders when my app is loaded. I tried $scope.apply(), but it throws error saying apply() is not available.

请帮忙。

推荐答案

既然你都可以从你需要做这样的角JS的出方的值,

Since you are getting the values from out side of the angular js you need to do it like this,

$scope.$apply(function(){
  $scope.ordercount = results.length;
})

这篇关于IndexedDB的回调angularjs不更新UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆