-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Add example on how to use the injector from outside Angular #5188
Conversation
Thanks for the PR!
If you need to make changes to your pull request, you can update the commit with Thanks again for your help! |
…Angular Sometimes you integrate Angular in an application that has been there for a while and not all parts of the app are written in Angular. If you need to dynamically add Controllers to that project from outside Angular (let's say jQuery) then this example is for you. No breaking changes
Joscha Feth |
Hi @joscha - thanks for this example. While the method you suggest certainly allows you to compile up new HTML on a page from outside an Angular app, I am not sure this is the best method. If you have an app that has no angular in it already then how are you adding angular in the first place? You could add in the angular markup before you bootstrap the app. I am doing something similar in my github chrome extension, where I really don't have access to the HTML beforehand! See https://github.com/petebacondarwin/github-pr-helper/blob/master/src/githubHacks.js If you are talking about adding new controllers in at a later stage then this could probably be done from within Angular too. Perhaps you could provide some more info about your specific case? |
Hi @petebacondarwin - our application is a huge legacy application based on jQuery mostly. We have our own (very old) legacy controller pattern that injects content into an iframe after page load. The only callback we have is within that legacy controller, so that's were we need to bootstrap any angular controllers that might have been loaded. The only other place that has angular at that point is the main app which got automatically bootstrapped on the document containing the iframe. I suppose I could access this application from within the callback - does that make you think of a better alternative of angularifying the new iframe content? |
I see so you have legacy code injecting DOM elements that contain angular markup inside an angular-app. Fair enough. |
@petebacondarwin exactly, and the code I proposed for the docs is working like a charm exactly for that... do you know what I need to do to make @mary-poppins re-check my CLA status and the commit message? |
Don't worry about Mary. She doesn't actually know anything about CLAs yet as they are not accessible outside of Google. |
Merged with tweaks. Thanks |
Sometimes you integrate Angular in an application that has been there for a while and not all parts of the app are written in Angular. If you need to dynamically add Controllers to that project from outside Angular (let's say jQuery) then this example is for you.