-
Notifications
You must be signed in to change notification settings - Fork 27.4k
ngMock - injector not attached to $rootElement #14022
Comments
As a workaround I can add it to the rootNode by myself, but then I know internals of Angular: |
Hm...I submitted #14034, but tbh I am not sure why you need to call |
@gkalpak My use case is similar to this one from an angular.injector documentation, so I have an angular app which is using separate framework for drawing in one of used directives (configured externally from JSON file, so I can't inject injector) |
Yeah, 3rd-party libs sound like a valid usecase. |
@jsuchenia @gkalpak sorry guys to be the bearer of bad news but this fix causes a memory leak in Karma + JQuery (a particular internal Google projects was having an issue with this). Therefore we need to revert this for now until we can have a solution that doesn't use |
#14098 fixes the leak. But if you need to revert it, go ahead and we'll figure it out later 😃 |
#14098 has neen merged. Relanded the fix along with appropriate meassures to prevent the leak. Let's see if something breaks 😃 |
Under ngMock when injector was already created it's not connected to a $rootElement, so:
$rootElement.injector()`
returns an undefined value.
I wish to use $rootElement to create sub-elements for test purposes, then tested piece of code can use:
angular.element(localElement).injector()
to retrieve already initialised injector.
The text was updated successfully, but these errors were encountered: