zoukankan      html  css  js  c++  java
  • 初学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>

  • 相关阅读:
    [HEOI2013]Segment
    决策单调性胡扯笔记
    HDU 4352 XHXJ's LIS
    WC前计划做但一定会鸽的事情
    LGP5667 拉格朗日插值2
    BZOJ3516 国王奇遇记加强版
    ### Paper about Event Detection
    ### GIT
    ###《Max-Margin Early Event Detectors》
    ### matlab
  • 原文地址:https://www.cnblogs.com/zhouxiaobai/p/9298940.html
Copyright © 2011-2022 走看看