Utilizing AngularJS (with ng-table), I am working on creating and synchronizing two arrays. In both tables, I have [A, B, C] values and my aim is to keep them synchronized. For instance, if I filter the first array with "A", I expect to see only [A] in the second one as well.
The issue appears to be that the $scope differs for the two tables even though they are on the same page, resulting in non-shared data between them. To address this, I attempted to make the controller the same using nb-controller
:
<table ng-table="tableParams" ng-controller="myController" id="tableA">
[...]
</table>
<table ng-table="tableParams" ng-controller="myController" id="tableB">
[...]
</table>
Unfortunately, this approach did not yield the desired outcome...
Below is an excerpt from my controller:
var data = ['A','B','C'];
$scope.tableParams = new ngTableParams({
page : 1, // show first page
count : 15, // count per page
filter : {
filter_dict : '{}',
},
sorting : {
id : 'asc',// initial sorting
}
},
{
counts: [15, 30, 50, 100],
total : $rootScope.data.length, // length of data
getData : function($defer, params) {
$defer.resolve(data.slice((params.page() - 1) * params.count(), params.page() * params.count()));
},
$scope:$scope
});
Any suggestions on what steps I should take next?
Thank you!