先定义指令:
app.directive(‘onFinishRender‘,function ($timeout) { return { restrict: ‘A‘, link: function (scope, element, attr) { if (scope.$last === true) { $timeout(function () { scope.$emit(‘ngRepeatFinished‘); // scope.isSelectShow = false; }); } } } });
然后再在控制器中进行监听,并调用初始化函数
$scope.$on(‘ngRepeatFinished‘, function(ngRepeatFinishedEvent) { var select = document.getElementById(‘mySelect‘); console.log(select); select.style ="width:100%;height:34px"; $(".js-example-basic-single").select2(); });
然后再在Html页面绑定:
<tbody ng-repeat="row in convertdisplayed|filter:filter |paging:page.index:page.size" on-finish-render="ngRepeatFinished">
原文地址:https://www.cnblogs.com/vonson/p/9330790.html
时间: 2024-10-09 16:00:27