mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-24 03:55:49 +08:00
docs(guide/Running in Production): ng-strict-di
Adding note about Strict DI mode. Closes #9908
This commit is contained in:
committed by
Caitlin Potter
parent
74981c9f20
commit
da960544f1
@@ -41,3 +41,35 @@ The page should reload and the debug information should now be available.
|
||||
|
||||
For more see the docs pages on {@link ng.$compileProvider#debugInfoEnabled `$compileProvider`}
|
||||
and {@link angular.reloadWithDebugInfo `angular.reloadWithDebugInfo`}.
|
||||
|
||||
## Strict DI Mode
|
||||
|
||||
Using strict di mode in your production application will throw errors when a injectable
|
||||
function is not
|
||||
{@link di#dependency-annotation annotated explicitly}. Strict di mode is intended to help
|
||||
you make sure that your code will work when minified. However, it also will force you to
|
||||
make sure that your injectable functions are explicitly annotated which will improve
|
||||
angular's performance when injecting dependencies in your injectable functions because it
|
||||
doesn't have to dynamically discover a function's dependencies. It is recommended to
|
||||
automate the explicit annotation via a tool like
|
||||
[ng-annotate](https://github.com/olov/ng-annotate) when you deploy to production (and enable
|
||||
strict di mode)
|
||||
|
||||
To enable strict di mode, you have two options:
|
||||
|
||||
```html
|
||||
<div ng-app="myApp" ng-strict-di>
|
||||
<!-- your app here -->
|
||||
</div>
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```js
|
||||
angular.bootstrap(document, ['myApp'], {
|
||||
strictDi: true
|
||||
});
|
||||
```
|
||||
|
||||
For more information, see the
|
||||
{@link di#using-strict-dependency-injection DI Guide}.
|
||||
|
||||
Reference in New Issue
Block a user