Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$compile isn't available on every DOM element #3

Open
stephanrauh opened this issue Dec 21, 2014 · 1 comment
Open

$compile isn't available on every DOM element #3

stephanrauh opened this issue Dec 21, 2014 · 1 comment

Comments

@stephanrauh
Copy link

I observed an error message on this line:

var $compile = angular.element(document).injector().get('$compile')

Requesting the injector() specifically from the controller element does the trick for me:

var theInjector = angular.element(document.querySelector('[ng-controller]')).injector();
var $compile = theInjector.get('$compile');
stephanrauh pushed a commit to stephanrauh/jsf-updates-angular that referenced this issue Dec 21, 2014
@marcorinck
Copy link
Owner

I think this is the root cause of most of your other problems with JUA. Sorry :-)

I haven't really understood what is happening here for you. Can you please elaborate what error message you are getting or maybe provide a little demo application?

However, your fix is causing other problems together with a fix you made in issue #6 (I think). This fix here is trying to get the injector out of the first ng-controller element, which seems to work at first ... after some time you saw its not anymore (see #6). I would bet, thats because you moved destroying of old scopes to the success phase of ajax requests in your fix for #6.

The problem is, that in the success phase JSF has already updated the DOM and deleted old DOM nodes and updated them with new ones. Destroying of old scopes is pointless now, as the DOM node which angular knew of don't exist anymore. And this is causing angular to not find the injector anymore.

I would very much like to investigate this problem further before accepting a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants