我正在使用 AngularJS 和 angular-datatable 库。我需要在单击行时调用模态。这是我的部分代码:
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;
}
console.log 函数在任何情况下都可以正常工作,但调用模态函数只有在超时时才能按预期工作。那么有人可以解释为什么会这样吗?为什么只有第一个功能有效?我将不胜感激任何解释。