aboutsummaryrefslogtreecommitdiffstats
path: root/docs/content/guide/dev_guide.services.injecting_controllers.ngdoc
diff options
context:
space:
mode:
Diffstat (limited to 'docs/content/guide/dev_guide.services.injecting_controllers.ngdoc')
-rw-r--r--docs/content/guide/dev_guide.services.injecting_controllers.ngdoc12
1 files changed, 0 insertions, 12 deletions
diff --git a/docs/content/guide/dev_guide.services.injecting_controllers.ngdoc b/docs/content/guide/dev_guide.services.injecting_controllers.ngdoc
index 75630b32..0046dd7f 100644
--- a/docs/content/guide/dev_guide.services.injecting_controllers.ngdoc
+++ b/docs/content/guide/dev_guide.services.injecting_controllers.ngdoc
@@ -3,11 +3,9 @@
@name Developer Guide: Angular Services: Injecting Services Into Controllers
@description
-
Using services as dependencies for controllers is very similar to using services as dependencies
for another service.
-
Since JavaScript is a dynamic language, DI can't figure out which services to inject by static
types (like in static typed languages). Therefore, you must specify the service name by using the
`$inject` property, which is an array containing strings with names of services to be injected.
@@ -16,7 +14,6 @@ IDs matters: the order of the services in the array will be used when calling th
with injected parameters. The names of parameters in factory function don't matter, but by
convention they match the service IDs.
-
<pre>
function myController($loc, $log) {
this.firstMethod = function() {
@@ -32,7 +29,6 @@ this.secondMethod = function() {
myController.$inject = ['$location', '$log'];
</pre>
-
<doc:example>
<doc:source>
<script type="text/javascript">
@@ -47,18 +43,15 @@ angular.service('notify', function(win) {
};
}, {$inject: ['$window']});
-
function myController(notifyService) {
this.callNotify = function(msg) {
notifyService(msg);
};
}
-
myController.$inject = ['notify'];
</script>
-
<div ng:controller="myController">
<p>Let's try this simple notify service, injected into the controller...</p>
<input ng:init="message='test'" type="text" name="message" />
@@ -73,19 +66,14 @@ it('should test service', function(){
</doc:example>
-
-
## Related Topics
-
{@link dev_guide.services.understanding_services Understanding Angular Services}
{@link dev_guide.services.creating_services Creating Angular Services}
{@link dev_guide.services.registering_services Registering Angular Services}
{@link dev_guide.services.managing_dependencies Managing Service Dependencies}
{@link dev_guide.services.testing_services Testing Angular Services}
-
## Related API
-
{@link api/angular.service Angular Service API}