0

I have some legacy code that injects into the DOM (a dialog) and I'm trying to rewrite some of the jQuery logic to work with angular data binding.

This HTML is injected outside of an angular controller (jquery UI dialog), like so:

      // Get jQuery to load the static content into the page
        $.get(windowFile, data => {
            $(windowName).html(data);
            this.ready();
            that.toggleVisibility();
        });

The HTML defines an ngController:

<div ng-controller="inventoryController">

However, just injecting it into the DOM isn't enough. The controller is never initialized. I can modify the opening code a bit.

How can I get the controller to be initialized when injected?

Vaughan Hilts
  • 2,839
  • 1
  • 20
  • 39
  • Does this help? http://stackoverflow.com/questions/15247518/initialize-angularjs-controller-after-append-some-html-into-dom – Jonathan Lerner Aug 05 '14 at 04:34
  • @JonathanLerner It sort of did, but it seems like something changed in between versions and another step was neccessary.. I looked at another page but have since figured it out. Should I write a comment on that page with the new required step, or write an answer here? – Vaughan Hilts Aug 05 '14 at 04:46
  • Write the answer here – Jonathan Lerner Aug 05 '14 at 04:50

0 Answers0