1

I have an issue where HTML obtained from a PartialView Ajax call isn't getting processed by AngularJS. The problem I have however, is that some JS is setting the element.html property after page load occurred. I can't really touch this JS as it's filled with more business rules than I know. Here is what appears to be going on.

MainPage - Has access to Angular scope

<dd class="log"></dd>

somefile.js - Not in Angular scope (but I can get the MainPage scope via JS if needed)

getDataTemplate('.log', 'testid');
function getDataTemplate(placeholder, id) {
    $.ajax({
        type: 'GET',
        url: '/Get/Data' + id,
        success: function (data, textStatus, xhr) {
            var placeHolder = $(placeholder);
            placeHolder.html(data);
        }
    });
};

The data returned from the "Get/Data" can be anything with Angular, say

<div>{{1+2}}</div>

Not sure where to go. I tried a few things, but nothing is working. Ideas?

Thanks!!!

Dave
  • 1,062
  • 8
  • 28
  • 1
    why aren't you using `$http`? you really should look into using `$compile` – Daniel A. White Apr 16 '15 at 17:03
  • You can create multiple ng app. Each ng-app has its own $rootScope from which you can call broadcast (= publish). See http://stackoverflow.com/questions/16846210/angular-bootstrap-to-run-multiple-angular-apps and http://stackoverflow.com/questions/24830679/why-we-use-rootscope-broadcast-in-angularjs – roland Apr 16 '15 at 17:09
  • 1
    @roland - thanks man, that was what I needed. Move over to an answer so I can mark it. – Dave Apr 16 '15 at 17:42
  • Thanks Dave. I did :) – roland Apr 17 '15 at 10:09

1 Answers1

0

You can create multiple ng-app.

Each ng-app has its own $rootScope from which you can call broadcast (publish).

See those additional, relevant links:

https://stackoverflow.com/questions/16846210/angular-bootstrap-to-run-https://stackoverflow.com/questions/24830679/why-we-use-rootscope-broadcast-in-angularjs

Community
  • 1
  • 1
roland
  • 7,695
  • 6
  • 46
  • 61