ng-inject
Description
The ng-inject directive injects registered injectables (services, factories,
etc.) into the current scope for direct access within templates or expressions.
This allows access to application state without having to create intermediary
controllers.
When applied to an element, the directive reads a semicolon-separated list of
injectables’ names from the ng-inject attribute and attempts to retrieve them
from the $injector. Each resolved injectable is attached to the current scope
under its corresponding name.
Parameters
ng-inject
Type:
stringRestrict:
ADescription:
A semicolon-separated list of injectable’ names to attach to current scope.Example:
<div ng-inject="userService;accountService"></div>
Demo
<section ng-app>
<div ng-inject="$window"></div>
{{ $window.document.location }}
</section>
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.