Loading an AngularJS directive after an already fully loaded controller

I've got an AngularJS project in which I want to load a directive from a package X just after a controller from package Y will be fully loaded.

My main problem is that the controller is retrieving some data from a db and the directive needs that data to work as expected. Right now, the directive is finishing its loading before the data is fully loaded, so it doesn't work properly.

I need to get the directive starts to work when the controller (and what's more important, the data!) will be fully loaded.

Any suggestion?

Thanks in advance!

Your problem calls for working with promises.

Angular's $q is based on Kriskowal's Q.

Also check out this video by the famouse Egghead for some extra information: Egghead.