ng-table: Error: settings.$scope.$emit is not a function
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();
}
}
About this issue
- Original URL
- State: open
- Created 10 years ago
- Comments: 50 (3 by maintainers)
Had the same problem. Hasi’s solution fixed it pretty easily. Thanks!
I also had the same issue and after 2 days of a struggle managed to fix it using folliwing code line just after the
For more info please refer https://github.com/esvit/ng-table/blob/master/src/scripts/04-controller.js#L33