当我在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完成在指令工作之前。 我真的很感激在这个问题上给予任何形式的帮助。 提前致谢