我正在尝试重新呈现指令内容,我尝试了多个解决方案,我发现但大多数冻结浏览器或只是不起作用,这是我的指令:
angular.module('app.common.directives')
.directive('stColumns', function ($compile, $window, $timeout) {
return {
require: '^stTable',
compile: function(tElement, tAttrs, transclude) {
var displayIdx = $window.innerWidth > 1000 ? 'display' : 'displaySm';
tElement.find('tr').each(function(idx, el) {
$(el).find('td, th').each(function(tdIdx, td) {
$(td).attr('ng-if', 'stColumnsStatus[' + tdIdx + '] && stColumnsStatus[' + tdIdx + '].' + displayIdx);
});
});
return {
post: function(scope, iElem, attr) {
scope.stColumnsStatus = scope[attr.stColumns];
}
}
}
};
});
添加列定义的简单智能表插件,我想添加的想法是在用户调整窗口大小后重新渲染整个表格,以便显示“幻灯片”。变量将改变以适合窗口。
我是棱角分明的新人,所以我也不确定我做得对吗:)。