question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: settings.$scope.$emit is not a function

See original GitHub issue

Hey there, just wanted to start off by saying how much I appreciate the project and the work that’s been going into it.

Anyways, 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;

        //Removed code that processes the response. 

        };
        //Enables new data to be loaded, e.g. on a new address.
        //Pretty sure it's not working right now.
        if ($scope.tableParams){
            $scope.tableParams.reload();
        } 
        data = transactions; //this data var is what is called by the tables. Unsure if can remove.
        $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();
    } 
}

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:50 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Marcel-Hrnecekcommented, Sep 11, 2014

Had the same problem. Hasi’s solution fixed it pretty easily. Thanks!

1reaction
hasicommented, Sep 6, 2014

I also had the same issue and after 2 days of a struggle managed to fix it using folliwing code line just after the

$scope.tableParams = new ngTableParams(
{...},
{...}
);
 $scope.tableParams.settings().$scope = $scope;

For more info please refer https://github.com/esvit/ng-table/blob/master/src/scripts/04-controller.js#L33

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angularjs: $scope.emit is not working - Stack Overflow
The problem i have is that $scope.$emit does not seem to be working, i am looking for ways to contact functions between controllers...
Read more >
$rootScope.Scope - AngularJS: API
Overview. A root scope can be retrieved using the $rootScope key from the $injector. Child scopes are created using the $new() method.
Read more >
$scope.$on function is not running - Google Groups
Hi everybody, I'm trying to use $scope.$on and $rootScope.$broadcast in order to use a variable of a controller function in another controller function....
Read more >
Working with $scope.$emit and $scope.$on - javascript tutorial
emit . If scope of firstCtrl is parent of the secondCtrl scope: function firstCtrl($scope) { $scope ... $rootScope listener are not destroyed automatically....
Read more >
EventEmitter - Angular
Parameters. value, T. The value to emit. Optional. Default is undefined .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found