Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit fad4dc0

Browse files
committed
fix(ngMock): attach $injector to $rootElement
Fixes #14022 Closes #14034
1 parent 373f054 commit fad4dc0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/ngMock/angular-mocks.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1879,9 +1879,9 @@ angular.mock.$RAFDecorator = ['$delegate', function($delegate) {
18791879
*
18801880
*/
18811881
angular.mock.$RootElementProvider = function() {
1882-
this.$get = function() {
1883-
return angular.element('<div ng-app></div>');
1884-
};
1882+
this.$get = ['$injector', function($injector) {
1883+
return angular.element('<div ng-app></div>').data('$injector', $injector);
1884+
}];
18851885
};
18861886

18871887
/**

test/ngMock/angular-mocksSpec.js

+4
Original file line numberDiff line numberDiff line change
@@ -1576,6 +1576,10 @@ describe('ngMock', function() {
15761576
it('should create mock application root', inject(function($rootElement) {
15771577
expect($rootElement.text()).toEqual('');
15781578
}));
1579+
1580+
it('should attach the `$injector` to `$rootElement`', inject(function($injector, $rootElement) {
1581+
expect($rootElement.injector()).toBe($injector);
1582+
}));
15791583
});
15801584

15811585

0 commit comments

Comments
 (0)