网络SQL / SQL精简版和粘合角到行 [英] Web sql/Sql Lite and Binding to Row in Angular

查看:120
本文介绍了网络SQL / SQL精简版和粘合角到行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个棱角分明的PhoneGap应用程序。我本来以为绑定到我的情况下,该数据库查询的回报, result.rows 将是可能的,但现在看来似乎并非如此。我能得到这个工作的唯一方法是用注释掉code,其中我手动行的数据推到一个数组一行。这是唯一的办法?

该实际结合 .rows 收到的错误是:错误:在一个中继器不允许重复。中继器:在项目的项目重点:未定义:未定义

该服务:

显示code的

  //只有部分
查询:功能(Q){
        变种D = $ q.defer();
        变种分贝= this.getDb();        db.transaction(功能(T){
            t.executeSql(Q,[],功能(德克萨斯州,结果){
                d.resolve(结果);
            },功能(错误){
                d.reject(ERR);
            });        },功能(错误){
            d.reject(ERR);
        }
        );        返回d.promise;
     }

该控制器是这样的:

  Sql.query('选择DEMO *')。然后(功能(数据){
                的console.log(数据);
                //$scope.items = [];                //为(i = 0,1 = data.rows.length; I<升;我++){
                    //$scope.items.push(data.rows.item(i));
                //}                $ scope.items = data.rows; //这个错误了
                $ $范围safeApply()。
            });

中继器只是一个简单的:

 < D​​IV NG重复=项中的项目'> {{item.id}} {{item.data}}< / DIV>


解决方案

根据看起来你有一个以上的未定义在<$ C项错误信息$ C> data.rows 阵列。

您的工作code使用 data.rows.item(我)是创建一个新的空对象,而不是不确定?尝试改变 data.rows.item(我) data.rows [I] 在你的工作code这是否打破呢?

假设你在这里采用了棱角分明1.1.5一些选项:


  • 使用您当前的解决方法

  • 降级到1.1.4或当前稳定的1.0.7。我觉得1.1.4基于一个破版本1.1.5 和与1.1.4 的工作版本。

  • 删除任何重复的未定义从行 data.rows


注:对于具有类似的错误类型角度产生别人 $$ hashKey 做一个时,对象纳克重复。此错误表示相同的对象是数组中(使用相同的 $$ hashKey )和1.1.5是不允许的(后来?)。

请参阅此博客文章谷歌网上论坛帖子​​获取更多信息。另外这款拉申请看起来相关的,所以我不知道这种行为的目的是展望未来,虽然它似乎已经定格在了过去。

This is for a phonegap angular app. I would have thought binding to the db query return, result.rows in my case would be possible but it seems like it is not. The only way I could get this to work was with the commented out code where I manually push the data into an array row by row. Is this the only way?

The actually error received by binding to .rows is: Error: Duplicates in a repeater are not allowed. Repeater: item in items key: undefined:undefined

The service:

// only portion of code shown
query: function (q) {
        var d = $q.defer();
        var db = this.getDb();

        db.transaction(function (t) {
            t.executeSql(q, [], function (tx, results) {
                d.resolve(results);
            }, function (err) {
                d.reject(err);
            });

        }, function (err) {
            d.reject(err);
        }
        );

        return d.promise;
     }

The controller is like this:

  Sql.query('select * from DEMO').then(function (data) {
                console.log(data);
                //$scope.items = [];

                //for (i = 0, l = data.rows.length; i < l; i++) {
                    //$scope.items.push(data.rows.item(i));
                //}

                $scope.items = data.rows;  // this errors out
                $scope.$safeApply();
            });

The repeater is just a simple:

<div ng-repeat='item in items'>{{item.id}} {{item.data}}</div>

解决方案

Based on the error message it looks like you have more than one undefined item in the data.rows array.

Your working code uses data.rows.item(i) is that creating an new empty object instead of undefined? Try changing data.rows.item(i) to data.rows[i] in your working code does that break as well?

Assuming you are using angular 1.1.5 here are some options:


Note: For others having a similar type of error Angular generates a $$hashKey to objects when doing an ng-repeat. This error indicates the same object is in the array (with the same $$hashKey) and is not allowed in 1.1.5 (and later?).

See this blog post and google groups post for more info. Also this pull request looks related so I'm not sure if this behavior is intended going forward though it appears to have been fixed in the past.

这篇关于网络SQL / SQL精简版和粘合角到行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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