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

Commit da96054

Browse files
Kent C. Doddscaitp
Kent C. Dodds
authored andcommitted
docs(guide/Running in Production): ng-strict-di
Adding note about Strict DI mode. Closes #9908
1 parent 74981c9 commit da96054

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

docs/content/guide/production.ngdoc

+32
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,35 @@ The page should reload and the debug information should now be available.
4141

4242
For more see the docs pages on {@link ng.$compileProvider#debugInfoEnabled `$compileProvider`}
4343
and {@link angular.reloadWithDebugInfo `angular.reloadWithDebugInfo`}.
44+
45+
## Strict DI Mode
46+
47+
Using strict di mode in your production application will throw errors when a injectable
48+
function is not
49+
{@link di#dependency-annotation annotated explicitly}. Strict di mode is intended to help
50+
you make sure that your code will work when minified. However, it also will force you to
51+
make sure that your injectable functions are explicitly annotated which will improve
52+
angular's performance when injecting dependencies in your injectable functions because it
53+
doesn't have to dynamically discover a function's dependencies. It is recommended to
54+
automate the explicit annotation via a tool like
55+
[ng-annotate](https://github.com/olov/ng-annotate) when you deploy to production (and enable
56+
strict di mode)
57+
58+
To enable strict di mode, you have two options:
59+
60+
```html
61+
<div ng-app="myApp" ng-strict-di>
62+
<!-- your app here -->
63+
</div>
64+
```
65+
66+
or
67+
68+
```js
69+
angular.bootstrap(document, ['myApp'], {
70+
strictDi: true
71+
});
72+
```
73+
74+
For more information, see the
75+
{@link di#using-strict-dependency-injection DI Guide}.

0 commit comments

Comments
 (0)