0

I am making ul-li list using angular ng-repeat. But on DOMReady i want total length of that list that has been generated and i want to run an event on that li on "hover" or "click". But the length iam getting is 0 and no event is firing. What can be the best method to get that? Thanks in advance!

 <ul class="megamenuUL">
        <li ng-class="{'active':$index==0}" data-ng-repeat="cg in GroupList">
</li>
    </ul>
    <script>

        $(document).ready(function () {
          console.log($("ul.megamenuUL > li").length);
    });
    </script >

events that i need to fire on hover of that li

 $("#divOffers ul.megamenuUL > li > a").hover(function () {

                   $("#divOffers .megamenuUL > li").removeClass('active');
                   $(this).parent().find("#divOffers ul.megasubmenu li").removeClass('active');
                   $(this).parent().find("#divOffers ul.megasubmenu li:eq(0)").addClass('active');
                   $(this).parent().addClass('active');
               });

U see , i cant use angular for this

worlock
  • 190
  • 1
  • 18
  • You don't have to use jquery just for events binding,same thing is possible with angular itself ,refer @schlangguru's comment – dreamweiver Sep 29 '15 at 13:51