JJJCoder
JJJCoder

Reputation: 16926

AngularJs Directives Loaded Event

I have just started using AngularJs directives, using the resources here, here and here.

I have a situation where i need to do something after all directives have been loaded.

i.e

Scenario 1

Scenario 2

I can't seem to find a 'directives loaded' event. With a search, the best I could find was this SO post, (for which this answer does work), but it feels like a 'broad brush' approach.

What is the correct way of doing this please?

Happy to post code if needed, but it doesn't seem beneficial in this instance.

Upvotes: 7

Views: 13274

Answers (2)

JJJCoder
JJJCoder

Reputation: 16926

For the benefit of searchers...

@jack.the.ripper 's comment was correct. The SignalR stuff did need moving out to a service.

In the case of notifying when all directives were loaded, this has been working nicely.

Upvotes: 0

Michael Kang
Michael Kang

Reputation: 52837

You can use $timeout to execute a function after all the directives have been compiled, linked, and rendered.

$timeout(function() { 
    // do something here
});

Upvotes: 15

Related Questions