I've recently started working with AngularJS and the angular-datatable library. One problem I am facing is how to trigger a modal to pop up when a row is clicked. Here's a snippet of my code:
function rowCallback(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
// Unbind first in order to avoid any duplicate handler (see https://github.com/l-lin/angular-datatables/issues/87)
$('td', nRow).unbind('click');
$('td', nRow).bind('click', function() {
console.log(aData.title);
$timeout(function(){
Modal.showModal({
template : 'views/Modal.html',
Data : aData
});
}, 0);
});
return nRow;
}
While the console.log function seems to be working fine, the modal invocation function only works as expected when wrapped in a timeout. Can anyone shed some light on why this might be happening? Why does the first function work smoothly while the modal invocation requires a timeout? Your insights would be greatly appreciated.