初学angular项目中遇到的一些问题

1、当angular渲染完成后操作DOM树方法

//当数据渲染完毕

ngApp.directive('repeatFinish', function () {
            return {
                link: function (scope, element, attr) {
                    if (scope.$last == true) {
                        console.log('ng-repeat执行完毕')
                       
                        //初始左菜单
                        $(".first-nav").eq([idxData.idx_mod1]).find("span").addClass('open')
                        $(".first-nav").eq([idxData.idx_mod1]).parent("li").addClass('open')
                        $(".first-nav").eq([idxData.idx_mod1]).next("ul").css("display", "block")

scope.$eval(attr.repeatFinish)
                        
                    }
                }
            }
        })
//当angular数据加载完成之后操作dom元素
            $scope.renderFinish = function () {

console.log('渲染完之后的操作,操作jquery')
               }

在循环标签上添加

<ul style="" class="second-list" >
        <li class="second-item" repeat-finish="renderFinish()"  ng-repeat="sub in super.children" > </li>
   </ul>

2、angular循环套循环方法

<ul id="sys-sidebar-menu" class="page-sidebar-menu" data-keep-expanded="false" data-auto-scroll="true" data-slide-speed="200">
                            <li ng-repeat="item in modules" >
                                <a class="first-nav" href="javascript:;" >
                                    <span class="icon-arrow" ></span>
                                    <span class="title">{{::item.name}}</span>
                                </a>
                                <ul style="font-size:14px;color:#333" class="second-bar" >
                                    <li role="presentation" ng-repeat="items in item.children track by $index" >
                                    </li>
                                </ul>
                            </li>
                        </ul>

上一篇:mxnet实战系列(一)入门与跑mnist数据集


下一篇:ATT&CK实战系列——红队实战(一)