I am having a really hard time getting my application to be event-based whilst using AngularJS. In jQuery, it is extremely easy to check when the DOM is loaded into the document, so that event listeners can be bound to the new DOM. However, I am trying to get this same effect in Angular and I cannot find a way that is not "hacky".
For example, I am using ng-include
to add partial views to the DOM when an overlay is added to the document and a single <div>
is displayed for the user to interact with. However, I cannot center this <div>
correctly because I need to run JavaScript after it is loaded in order to center it properly.
I tried using ng-init="center()"
in my partial views, but I don't think Angular is re-compiling the view after it gets added, therefore the ng-init
is never getting called. What can I do to get this event-based functionality without doing some weird hack?