ng-repeat finish event

前端 未结 15 2630
盖世英雄少女心
盖世英雄少女心 2020-11-22 02:15

I want to call some jQuery function targeting div with table. That table is populated with ng-repeat.

When I call it on

$(document).r         


        
15条回答
  •  借酒劲吻你
    2020-11-22 02:55

    There is no need of creating a directive especially just to have a ng-repeat complete event.

    ng-init does the magic for you.

      

    the $last makes sure, that finished only gets fired, when the last element has been rendered to the DOM.

    Do not forget to create $scope.finished event.

    Happy Coding!!

    EDIT: 23 Oct 2016

    In case you also want to call the finished function when there is no item in the array then you may use the following workaround

    //or

    Just add the above line on the top of the ng-repeat element. It will check if the array is not having any value and call the function accordingly.

    E.g.

提交回复
热议问题