我正在尝试重新渲染指令内容,我尝试了多种解决方案,但其中大多数会冻结浏览器或根本不起作用,这是我的指令:
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];
}
}
}
};
});
添加列定义的简单智能表插件,我想添加的想法是在用户调整窗口大小后重新渲染整个表,以便“displayIdx”变量将更改以适应窗口。
我是角度新手,所以我也不确定我做得对:)