在ngTables,运行$ scope.tableParams.reload()在类型错误的第三次结果:不能设置为空值的属性“$ DATA” [英] In ngTables, running $scope.tableParams.reload() for the third time results in TypeError: Cannot set property '$data' of null

查看:320
本文介绍了在ngTables,运行$ scope.tableParams.reload()在类型错误的第三次结果:不能设置为空值的属性“$ DATA”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是错误的问候到 ngTable 插件AngularJS。

我似乎有一个很奇怪的错误。基本上,我可以没有任何问题运行 $ scope.tableParams.reload()两次,但在第三个执行,每下一个,我收到以下错误:

 类型错误:在无法设置为null的特性$ DATA[删除] /ng-table.js:411:55

我相信这是所有相关的code,但如果缺少任何物品让我知道:

  $ scope.lookupAddress =功能(地址){
    VAR URL ='https://blockchain.info/multiaddr?cors=true&active='+address;
    $ scope.loading = TRUE;
    $ scope.clearTableData();
    $ http.get(URL).success(功能(数据){
        $ scope.loading = FALSE;
        $ scope.loaded = TRUE;
        $ scope.loadError = FALSE;
        = glob的数据;        //我相信未来几年的循环,和交易的分配,是不相关的找到code。话虽这么说,我已经包括了它,因为错误隐藏在哪里你最不希望它。
        为(ⅰ= data.txs.length -1;我-1个;我 - ){
            变种inputAddr = [];
            对于(Z = 0; z,其中,data.txs [I] ['输入']长度;ž++){
                inputAddr.push(data.txs [I] ['输入'] [Z] ['$ P​​ $ PV_OUT'] ['地址'])
            }
            变种outputAddr = [];
            对于(Z = 0; z,其中,data.txs [I] ['出来']长度;ž++){
                outputAddr.push(data.txs [I] ['出来'] [Z] ['地址'])
            }
            交易[I] = {
                哈希:data.txs [I] ['散'],
                金额:data.txs [I] ['结果'] /亿,
                平衡:data.txs [I] ['平衡'] /亿,
                InputAddress':inputAddr,
                OutputAddress':outputAddr,
                日期:timeConverter(data.txs [I] ['时间'])
            };
        };        //你也可以忽略这个太...大概。
        $ scope.output = {
            BTC:data.wallet.final_balance /亿,//在聪回应,所以不得不分开。
            地址:地址,
            接收的总':data.addresses [0] .total_received /亿,
            总发送:data.addresses [0] .total_sent /亿,
            交易:交易
        };
        //使要加载的新数据,例如上一个新的地址。
        如果($ scope.tableParams){
            $ scope.tableParams.reload();
        }
        数据=交易;
        $ scope.tableParams =新ngTableParams({
            页面:1,
            数:5,//每页项目
            排序:{
                日期:'说明'
            }
        },{
            总:transactions.length,
            的getData:函数($延迟,则params){
                数据=交易;
                VAR orderedData = params.sorting()? $过滤器('排序依据')(数据,params.orderBy()):数据;
                $ defer.resolve(orderedData.slice((params.page() - 1)* params.count(),params.page()* params.count()));            }
        });
    })。
    错误(功能(数据){
        $ scope.loadError =真;
    });
}$ scope.clearTableData =功能(){
    交易= [];
    $ scope.output = {}
    如果($ scope.tableParams){
            $ scope.tableParams.reload();
    }
}


解决方案

我知道这是为时已晚,但我想更好地发表评论,这对于其他人谁寻求在同一问题上的答案。

我也有同样的问题,并设法通过遵循以下网址的例子来解决。

<一个href=\"https://github.com/esvit/ng-table/blob/master/src/scripts/04-controller.js\">https://github.com/esvit/ng-table/blob/master/src/scripts/04-controller.js

我只是添加了以下code线到ngTableParams创建实例后,我的code。

  $ scope.params.settings()$范围= $范围;

This error is in regards to the ngTable plugin for AngularJS.

I seem to be having a really weird error. Basically, I can run $scope.tableParams.reload() twice with no problem, but on the third execution, and every following one, I get the following error:

TypeError: Cannot set property '$data' of null at [removed]/ng-table.js:411:55

I believe this is all the relevant code, but if anything is missing let me know:

$scope.lookupAddress = function(address){       
    var url = 'https://blockchain.info/multiaddr?cors=true&active='+address;
    $scope.loading = true;
    $scope.clearTableData();
    $http.get(url).success(function(data){
        $scope.loading = false;
        $scope.loaded = true;
        $scope.loadError = false;
        glob = data;

        //I believe the next few for loops, and the assignment of transactions, is not relevant to finding the code.  That being said, I've included it because bugs hide where you least expect it.
        for (i = data.txs.length -1; i > -1; i-- ){
            var inputAddr = []; 
            for (z = 0; z < data.txs[i]['inputs'].length; z++){
                inputAddr.push(data.txs[i]['inputs'][z]['prev_out']['addr'])
            }
            var outputAddr = [];
            for (z = 0; z < data.txs[i]['out'].length; z++){
                outputAddr.push(data.txs[i]['out'][z]['addr'])
            }
            transactions[i] = {
                'Hash' : data.txs[i]['hash'],
                'Amount' : data.txs[i]['result'] / 100000000,
                'Balance' : data.txs[i]['balance'] / 100000000,
                'InputAddress' : inputAddr,
                'OutputAddress' : outputAddr,
                'Date' : timeConverter(data.txs[i]['time'])
            };
        };

        //You can also ignore this too... probably.
        $scope.output = {
            'BTC' : data.wallet.final_balance / 100000000, //Response in satoshi, so have to divide.
            'Address' : address,
            'Total Received': data.addresses[0].total_received / 100000000,
            'Total Sent': data.addresses[0].total_sent / 100000000,
            'Transactions' : transactions
        };
        //Enables new data to be loaded, e.g. on a new address.
        if ($scope.tableParams){
            $scope.tableParams.reload();
        } 
        data = transactions;
        $scope.tableParams = new ngTableParams({
            page: 1,            
            count: 5,           // items per page
            sorting: {
                Date: 'desc' 
            }
        }, {
            total: transactions.length, 
            getData: function($defer, params) {
                data = transactions;
                var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
                $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));

            }
        });
    }).
    error(function(data){
        $scope.loadError = true;
    });
}

$scope.clearTableData = function(){
    transactions = [];
    $scope.output = {}
    if ($scope.tableParams){
            $scope.tableParams.reload();
    } 
}

解决方案

I know this is too late, but I thought better to comment on this for others who seeking for a answer for the same issue.

I also had the same issue and managed to fix by following the example in following URL.

https://github.com/esvit/ng-table/blob/master/src/scripts/04-controller.js

I just added the following code line into my code after 'ngTableParams' instance creation.

$scope.params.settings().$scope = $scope;

这篇关于在ngTables,运行$ scope.tableParams.reload()在类型错误的第三次结果:不能设置为空值的属性“$ DATA”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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