This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
docs(guide/Running in Production): ng-strict-di #9908
Closed
Closed
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e106371
docs(guide/Running in Production): ng-strict-di
40fbdc9
Using link helper
43877e7
docs(guide/Running in Production): ng-strict-di
22ba437
docs(guide/Running in Production): ng-strict-di
22a87b6
docs(guide/Running in Production): ng-strict-di
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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). | ||
This will force you to make sure that your injectable functions are implicitely annotated | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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!