Skip to content

Commit 4db67c3

Browse files
author
Kent C. Dodds
committed
feat($injector): add strictDi property to $injector instance
Add a strictDi property which is true or false when creating an instance of an injector. Closes angular#11728
1 parent c10b249 commit 4db67c3

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/auto/injector.js

+2
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,8 @@ function createInjector(modulesToLoad, strictDi) {
646646

647647
forEach(loadModules(modulesToLoad), function(fn) { instanceInjector.invoke(fn || noop); });
648648

649+
instanceInjector.strictDi = strictDi;
650+
649651
return instanceInjector;
650652

651653
////////////////////////////////////

test/auto/injectorSpec.js

+8
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ describe('injector', function() {
116116
expect($injector).not.toBe(providerInjector);
117117
}));
118118

119+
it('should have an false strictDi property', inject(function($injector) {
120+
expect($injector.strictDi).toBe(false);
121+
}));
122+
119123

120124
describe('invoke', function() {
121125
var args;
@@ -1036,4 +1040,8 @@ describe('strict-di injector', function() {
10361040
inject(function($test) {});
10371041
expect(called).toBe(true);
10381042
});
1043+
1044+
it('should set strictDi property to true on the injector instance', inject(function($injector) {
1045+
expect($injector.strictDi).toBe(true);
1046+
}));
10391047
});

0 commit comments

Comments
 (0)