I am using Angular.js and DataTables to load a big list of data. This is using server side processing, so the page is loaded, and then the DataTable loads.
My table has two columns of checkboxes that I am trying to bind to an angular root scope variable. Here is the code where I set my rootscope variable as a placeholder.
ultModule.run(function($rootScope) {
$rootScope.report = {
disavow: { domains: [], urls: [] }
};
});
The following function is called by my controller to retrieve the saved data and to save the reason variable in the report.disavow (checkbox data to save) object.
function setSelectionData($rootScope, $http) {
/* Checkbox Initial Data */
$http({
method: 'POST',
url: '../ajax-targets/get-report-selected.php',
data : { 'id': $rootScope.report.id }
}).success(function(data, status, headers, config) {
if(data.error) { alert(data.msg); }
$rootScope.report.disavow = data;
}).error(function(data, status, headers, config) {
alert('There was an error starting the process. Please try again later.');
});
/* Checkbox Handeling */
$rootScope.toggelSelected = function(type, id, reason) {
if(type === 'domain') {
$rootScope.disavow.domains[id].reason = reason;
} else {
$rootScope.disavow.urls[id].reason = reason;
}
var a = $rootScope.disavow;
}
}
ultController.controller('CtrlReportStats', function($rootScope, $scope, $routeParams, $http) {
setRootScopeParams($rootScope, $http, $routeParams.reportSha);
});
This is an example of the checkbox that I would like to bind to the report.disavow object.
<input type="checkbox" data-ng-model="report.disavow.domains[20378].checked" data-ng-change="toggelSelected('20378', 'url', 'bad-link')">
This code works perfectly if I paste the checkbox tag (above) into the partial.html. If I return this and put it in the datatable it doesn't do anything.
I believe that I need to tell Angular to check the page again and bind to any objects. I'm looking through the docs but haven't found what I'm looking for. Can anyone point me in the right direction? Please and thank you.