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

docs(guide/Running in Production): ng-strict-di #9908

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions docs/content/guide/production.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,34 @@ 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
[annotated implicitly](https://docs.angularjs.org/guide/di#dependency-annotation#implicit-annotation).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the {@link } helper?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure, I'll look at how to do that. Thanks!

This will force you to make sure that your injectable functions are implicitely annotated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: implicitly

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 implicite annotation via a tool like
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: implicit

[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
[DI Guide](https://docs.angularjs.org/guide/di#using-strict-dependency-injection).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{@link ... } should be used here too.