当我在 firefox 中调试时,调试器应该输入指令:
dialogApp.directive('myTable', function($timeout) {
return function(scope, element, attrs) {
$timeout(function(){
// apply DataTable options, use defaults if none specified by user
var options = {};
if (attrs.myTable.length > 0) {
options = scope.$eval(attrs.myTable);
} else {
options = {
"bStateSave": true,
"iCookieDuration": 2419200, /* 1 month */
"bJQueryUI": true,
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bInfo": false,
"bDestroy": true
};
}
// Tell the dataTables plugin what columns to use
// We can either derive them from the dom, or use setup from the controller
var explicitColumns = [];
// element.find('th').each(function(index, elem) {
// explicitColumns.push($(elem).text());
//});
if (explicitColumns.length > 0) {
options["aoColumns"] = explicitColumns;
} else if (attrs.aoColumns) {
options["aoColumns"] = scope.$eval(attrs.aoColumns);
}
// aoColumnDefs is dataTables way of providing fine control over column config
if (attrs.aoColumnDefs) {
options["aoColumnDefs"] = scope.$eval(attrs.aoColumnDefs);
}
if (attrs.fnRowCallback) {
options["fnRowCallback"] = scope.$eval(attrs.fnRowCallback);
}
// apply the plugin
var dataTable = element.dataTable(options);
// new FixedColumns( dataTable);
// watch for any changes to our data, rebuild the DataTable
scope.$watch(attrs.aaData, function(value) {
var val = value || null;
if (val) {
dataTable.fnClearTable();
dataTable.fnAddData(scope.$eval(attrs.aaData));
}
});
},1000);
};
});
调试停止并且没有进一步呈现。这是一个演示,我正在使用动态标题创建表(该指令的主要思想已从网络本身中挑选)。引入使用超时的延迟以允许 ng-repeat 在指令工作之前完成. 我非常感谢在这个问题上提供任何形式的帮助。提前致谢