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!!!

4
  • 1
    why aren't you using $http? you really should look into using $compile Commented Apr 16, 2015 at 17:03
  • You can create multiple ng app. Each ng-app has its own $rootScope from which you can call broadcast (= publish). See stackoverflow.com/questions/16846210/… and stackoverflow.com/questions/24830679/… Commented Apr 16, 2015 at 17:09
  • 1
    @roland - thanks man, that was what I needed. Move over to an answer so I can mark it. Commented Apr 16, 2015 at 17:42
  • Thanks Dave. I did :) Commented Apr 17, 2015 at 10:09

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.