Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Recursive ng-include - How to know when entire tree is rendered #6567

@parliament718

Description

@parliament718

I'm trying to render a hierarchical tree recursively using ng-include. Here is a fiddle

The problem is in my link function gets called before the rendering is done to try to initialize a menu plugin on an empty list.

link: function (scope, element, attrs) {

    var $menus = element.find("ul");

    //Prints empty element        
    console.log($menus.html());

    //No real $menus to initialize 
    //$menus.menuAim({ });

}

I know there is onload on ng-include, but I don't want to resort to some ugly hack like incrementing a counter on each onload and comparing against count of elements, as calculating the count gets tricky due to the hierarchy structure.

What's a cleaner way to know when the ng-include has finished a full recursive rendering and all elements are on the page?

I tried using postLink instead of link but directive still prints an empty

    :

    link: {
         pre: angular.noop,
         post: function(scope, element, attrs){
              //no difference
         }
    }
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions